@@ -38,32 +38,29 @@ export async function getFeedsForPublisherCached(
3838 return parse < z . infer < typeof priceFeedsSchema > > ( rawData ) ;
3939}
4040
41- const _privateGetFeeds = unstable_cache ( async ( cluster : Cluster ) => {
42- const start = Date . now ( ) ;
43- await new Promise ( ( resolve ) => setTimeout ( resolve , 10_000 ) ) ;
44- const feeds = await _getFeedsCached ( cluster ) as Omit < z . infer < typeof priceFeedsSchema > [ number ] , 'price' > [ ] ;
45- const end = Date . now ( ) ;
46- // eslint-disable-next-line no-console
47- console . log ( "internal getFeedsCached" , cluster , end - start ) ;
48- return feeds . map ( ( feed ) => ( {
49- ...feed ,
50- price : undefined ,
51- } ) ) ;
52- // const data = await fetch(`${PUBLIC_URL}/api/pyth/get-feeds?cluster=${cluster.toString()}&excludePriceComponents=true`, {
53- // next: {
54- // revalidate: DEFAULT_CACHE_TTL,
55- // },
56- // headers: {
57- // 'x-vercel-protection-bypass': VERCEL_AUTOMATION_BYPASS_SECRET,
58- // },
59- // });
60- // const dataJson = await data.text();
61- // const feeds: Omit<z.infer<typeof priceFeedsSchema>[0], "price">[] = parse(dataJson);
62- // return feeds;
63- } , [ 'getFeedsCached__' ] , {
64- revalidate : DEFAULT_CACHE_TTL ,
65- } ) ;
66-
41+ const _privateGetFeeds = async ( cluster : Cluster ) => {
42+ // const start = Date.now();
43+ // await new Promise((resolve) => setTimeout(resolve, 10_000));
44+ // const feeds = await _getFeedsCached(cluster) as Omit<z.infer<typeof priceFeedsSchema>[number], 'price'>[];
45+ // const end = Date.now();
46+ // // eslint-disable-next-line no-console
47+ // console.log("internal getFeedsCached", cluster, end - start);
48+ // return feeds.map((feed) => ({
49+ // ...feed,
50+ // price: undefined,
51+ // }));
52+ const data = await fetch ( `${ PUBLIC_URL } /api/pyth/get-feeds?cluster=${ cluster . toString ( ) } &excludePriceComponents=true` , {
53+ next : {
54+ revalidate : DEFAULT_CACHE_TTL ,
55+ } ,
56+ headers : {
57+ 'x-vercel-protection-bypass' : VERCEL_AUTOMATION_BYPASS_SECRET ,
58+ } ,
59+ } ) ;
60+ const dataJson = await data . text ( ) ;
61+ const feeds : Omit < z . infer < typeof priceFeedsSchema > [ 0 ] , "price" > [ ] = parse ( dataJson ) ;
62+ return feeds ;
63+ } ;
6764export const getFeedsCached = async ( cluster : Cluster ) => {
6865 const start = Date . now ( ) ;
6966 const data = await _privateGetFeeds ( cluster ) ;
0 commit comments