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 => {
37
37
}
38
38
} ;
39
39
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
+
40
47
export const parseCluster = ( name : string ) : Cluster | undefined =>
41
48
( CLUSTER_NAMES as readonly string [ ] ) . includes ( name )
42
49
? toCluster ( name as ( typeof CLUSTER_NAMES ) [ number ] )
@@ -65,14 +72,14 @@ export const getPublishersForFeed = async (
65
72
cluster : Cluster ,
66
73
symbol : string ,
67
74
) => {
68
- const data = await clients [ cluster ] . getData ( ) ;
75
+ const data = await getData ( cluster ) ;
69
76
return data . productPrice
70
77
. get ( symbol )
71
78
?. priceComponents . map ( ( { publisher } ) => publisher . toBase58 ( ) ) ;
72
79
} ;
73
80
74
81
export const getFeeds = async ( cluster : Cluster ) => {
75
- const data = await clients [ cluster ] . getData ( ) ;
82
+ const data = await getData ( cluster ) ;
76
83
return priceFeedsSchema . parse (
77
84
data . symbols . map ( ( symbol ) => ( {
78
85
symbol,
@@ -86,7 +93,7 @@ export const getFeedsForPublisher = async (
86
93
cluster : Cluster ,
87
94
publisher : string ,
88
95
) => {
89
- const data = await clients [ cluster ] . getData ( ) ;
96
+ const data = await getData ( cluster ) ;
90
97
return priceFeedsSchema . parse (
91
98
data . symbols
92
99
. filter (
You can’t perform that action at this time.
0 commit comments