Browse Source

chore: test with max memory setting

Alexandru Cambose 3 tháng trước cách đây
mục cha
commit
092cdd5e19

+ 1 - 0
apps/insights/next.config.js

@@ -4,6 +4,7 @@ const config = {
     reactCompiler: true,
   },
 
+  cacheMaxMemorySize: 200 * 1024 * 1024, // 200MB
   reactStrictMode: true,
 
   pageExtensions: ["ts", "tsx", "mdx"],

+ 3 - 2
apps/insights/src/components/Root/index.tsx

@@ -11,10 +11,11 @@ import {
 } from "../../config/server";
 import { LivePriceDataProvider } from "../../hooks/use-live-price-data";
 import { getPublishers } from "../../services/clickhouse";
-import { Cluster, getFeeds } from "../../services/pyth";
+import { Cluster } from "../../services/pyth";
 import { PriceFeedIcon } from "../PriceFeedIcon";
 import { PublisherIcon } from "../PublisherIcon";
 import { SearchButton as SearchButtonImpl } from "./search-button";
+import { getFeedsCached } from '../../server/pyth';
 
 export const TABS = [
   { segment: "", children: "Overview" },
@@ -76,7 +77,7 @@ const getPublishersForSearchDialog = async (cluster: Cluster) => {
 
 const getFeedsForSearchDialog = async (cluster: Cluster) => {
   "use cache";
-  const feeds = await getFeeds(cluster);
+  const feeds = await getFeedsCached(cluster);
 
   return feeds.map((feed) => ({
     symbol: feed.symbol,

+ 5 - 4
apps/insights/src/server/pyth.ts

@@ -1,7 +1,7 @@
 import superjson from "superjson";
 import { z } from 'zod';
 
-import { Cluster, clients, getFeeds, priceFeedsSchema } from "../services/pyth";
+import { Cluster, clients, priceFeedsSchema } from "../services/pyth";
 
 export const getPublishersForFeed = async (
   cluster: Cluster,
@@ -16,7 +16,7 @@ export const getPublishersForFeed = async (
   return result;
 };
 
-const getAllFeeds = async (cluster: Cluster) => {
+const getFeeds = async (cluster: Cluster) => {
   "use cache";
   const data = await clients[cluster].getData();
   
@@ -39,7 +39,7 @@ export const getFeedsForPublisherCached = async (
   cluster: Cluster,
   publisher: string,
 ) => {
-  const rawFeeds = await getAllFeeds(cluster);
+  const rawFeeds = await getFeeds(cluster);
   const feeds = superjson.parse<z.infer<typeof priceFeedsSchema>>(rawFeeds);
   return priceFeedsSchema.parse(feeds.filter(({ price }) =>
     price.priceComponents.some(
@@ -50,7 +50,8 @@ export const getFeedsForPublisherCached = async (
 
 export const getFeedsCached = async (cluster: Cluster) => {
   "use cache";
-  return getFeeds(cluster);
+  const rawFeeds = await getFeeds(cluster);
+  return superjson.parse<z.infer<typeof priceFeedsSchema>>(rawFeeds);
 };
 
 export const getPublishersForFeedCached = async (cluster: Cluster, symbol: string) => {

+ 0 - 40
apps/insights/src/services/pyth.ts

@@ -61,46 +61,6 @@ export const clients = {
   [Cluster.PythtestConformance]: mkClient(Cluster.PythtestConformance),
 } as const;
 
-export const getFeeds = async (cluster: Cluster) => {
-  const data = await clients[cluster].getData();
-  return priceFeedsSchema.parse(
-    data.symbols.map((symbol) => ({
-      symbol,
-      product: data.productFromSymbol.get(symbol),
-      price: {
-          ...data.productPrice.get(symbol),
-          priceComponents: data.productPrice.get(symbol)?.priceComponents.map(({ publisher }) => ({
-            publisher: publisher.toBase58(),
-          })) ?? [],
-        },
-    })),
-  );
-};
-
-export const getFeedsForPublisher = async (
-  cluster: Cluster,
-  publisher: string,
-) => {
-  const data = await clients[cluster].getData();
-  return priceFeedsSchema.parse(
-    data.symbols
-      .filter(
-        (symbol) =>
-          data.productFromSymbol.get(symbol)?.display_symbol !== undefined,
-      )
-      .map((symbol) => ({
-        symbol,
-        product: data.productFromSymbol.get(symbol),
-        price: data.productPrice.get(symbol),
-      }))
-      .filter(({ price }) =>
-        price?.priceComponents.some(
-          (component) => component.publisher.toBase58() === publisher,
-        ),
-      ),
-  );
-};
-
 export const priceFeedsSchema = z.array(
   z.object({
     symbol: z.string(),