File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed
apps/insights/src/services Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,13 @@ export const toCluster = (name: (typeof CLUSTER_NAMES)[number]): Cluster => {
3737 }
3838} ;
3939
40+ let inMemoryData : Awaited < ReturnType < typeof clients [ Cluster ] [ "getData" ] > > | undefined ;
41+
42+ const getData = async ( cluster : Cluster ) => {
43+ inMemoryData ??= await clients [ cluster ] . getData ( ) ;
44+ return inMemoryData ;
45+ } ;
46+
4047export const parseCluster = ( name : string ) : Cluster | undefined =>
4148 ( CLUSTER_NAMES as readonly string [ ] ) . includes ( name )
4249 ? toCluster ( name as ( typeof CLUSTER_NAMES ) [ number ] )
@@ -65,14 +72,14 @@ export const getPublishersForFeed = async (
6572 cluster : Cluster ,
6673 symbol : string ,
6774) => {
68- const data = await clients [ cluster ] . getData ( ) ;
75+ const data = await getData ( cluster ) ;
6976 return data . productPrice
7077 . get ( symbol )
7178 ?. priceComponents . map ( ( { publisher } ) => publisher . toBase58 ( ) ) ;
7279} ;
7380
7481export const getFeeds = async ( cluster : Cluster ) => {
75- const data = await clients [ cluster ] . getData ( ) ;
82+ const data = await getData ( cluster ) ;
7683 return priceFeedsSchema . parse (
7784 data . symbols . map ( ( symbol ) => ( {
7885 symbol,
@@ -86,7 +93,7 @@ export const getFeedsForPublisher = async (
8693 cluster : Cluster ,
8794 publisher : string ,
8895) => {
89- const data = await clients [ cluster ] . getData ( ) ;
96+ const data = await getData ( cluster ) ;
9097 return priceFeedsSchema . parse (
9198 data . symbols
9299 . filter (
You can’t perform that action at this time.
0 commit comments