@@ -51,12 +51,14 @@ export class PythHttpClient {
51
51
const prices = new Array < PriceData > ( )
52
52
53
53
// 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
+ ] )
55
58
56
59
// Populate products and prices
57
60
const priceDataQueue = new Array < PriceData > ( )
58
61
const productAccountKeyToProduct = new Map < string , Product > ( )
59
- const currentSlot = await this . connection . getSlot ( this . commitment )
60
62
61
63
// Initialize permission field as undefined
62
64
let permissionData
@@ -121,10 +123,12 @@ export class PythHttpClient {
121
123
*/
122
124
public async getAssetPricesFromAccounts ( priceAccounts : PublicKey [ ] ) : Promise < PriceData [ ] > {
123
125
const priceDatas : PriceData [ ] = [ ]
124
- const currentSlotPromise = this . connection . getSlot ( this . commitment )
125
- const accountInfos = await this . connection . getMultipleAccountsInfo ( priceAccounts , this . commitment )
126
126
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
+
128
132
for ( let i = 0 ; i < priceAccounts . length ; i ++ ) {
129
133
// Declare local variable to silence typescript warning; otherwise it thinks accountInfos[i] can be undefined
130
134
const accInfo = accountInfos [ i ]
0 commit comments