@@ -51,12 +51,14 @@ export class PythHttpClient {
5151 const prices = new Array < PriceData > ( )
5252
5353 // Retrieve data from blockchain
54- const accountList = await this . connection . getProgramAccounts ( this . pythProgramKey , this . commitment )
54+ const [ accountList , currentSlot ] = await Promise . all ( [
55+ this . connection . getProgramAccounts ( this . pythProgramKey , this . commitment ) ,
56+ this . connection . getSlot ( this . commitment ) ,
57+ ] )
5558
5659 // Populate products and prices
5760 const priceDataQueue = new Array < PriceData > ( )
5861 const productAccountKeyToProduct = new Map < string , Product > ( )
59- const currentSlot = await this . connection . getSlot ( this . commitment )
6062
6163 // Initialize permission field as undefined
6264 let permissionData
@@ -121,10 +123,12 @@ export class PythHttpClient {
121123 */
122124 public async getAssetPricesFromAccounts ( priceAccounts : PublicKey [ ] ) : Promise < PriceData [ ] > {
123125 const priceDatas : PriceData [ ] = [ ]
124- const currentSlotPromise = this . connection . getSlot ( this . commitment )
125- const accountInfos = await this . connection . getMultipleAccountsInfo ( priceAccounts , this . commitment )
126126
127- const currentSlot = await currentSlotPromise
127+ const [ accountInfos , currentSlot ] = await Promise . all ( [
128+ this . connection . getMultipleAccountsInfo ( priceAccounts , this . commitment ) ,
129+ this . connection . getSlot ( this . commitment ) ,
130+ ] )
131+
128132 for ( let i = 0 ; i < priceAccounts . length ; i ++ ) {
129133 // Declare local variable to silence typescript warning; otherwise it thinks accountInfos[i] can be undefined
130134 const accInfo = accountInfos [ i ]
0 commit comments