Skip to content

Commit 032af62

Browse files
committed
WIP: improve IH performance
1 parent d62a045 commit 032af62

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

apps/insights/src/components/Publisher/get-price-feeds.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import { ClusterToName, getFeedsForPublisher } from "../../services/pyth";
44
import { getStatus } from "../../status";
55

66
export const getPriceFeeds = async (cluster: Cluster, key: string) => {
7+
"use cache"
8+
79
const [feeds, rankings] = await Promise.all([
810
getFeedsForPublisher(cluster, key),
911
getRankingsByPublisher(key),

apps/insights/src/services/pyth.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,23 @@ const clients = {
5555
[Cluster.PythtestConformance]: mkClient(Cluster.PythtestConformance),
5656
} as const;
5757

58+
const getDataForCluster = (cluster: keyof typeof clients) => {
59+
"use cache";
60+
return clients[cluster].getData()
61+
}
62+
5863
export const getPublishersForFeed = async (
5964
cluster: Cluster,
6065
symbol: string,
6166
) => {
62-
const data = await clients[cluster].getData();
67+
const data = await getDataForCluster(cluster);
6368
return data.productPrice
6469
.get(symbol)
6570
?.priceComponents.map(({ publisher }) => publisher.toBase58());
6671
};
6772

6873
export const getFeeds = async (cluster: Cluster) => {
69-
const data = await clients[cluster].getData();
74+
const data = await getDataForCluster(cluster);
7075
return priceFeedsSchema.parse(
7176
data.symbols.map((symbol) => ({
7277
symbol,
@@ -80,7 +85,7 @@ export const getFeedsForPublisher = async (
8085
cluster: Cluster,
8186
publisher: string,
8287
) => {
83-
const data = await clients[cluster].getData();
88+
const data = await getDataForCluster(cluster);
8489
return priceFeedsSchema.parse(
8590
data.symbols
8691
.filter(

0 commit comments

Comments
 (0)