Skip to content

Commit 8021664

Browse files
committed
feat: conditional check on using ws account subscriber + unused
1 parent 9c05b62 commit 8021664

File tree

2 files changed

+6
-13
lines changed

2 files changed

+6
-13
lines changed

sdk/src/accounts/webSocketDriftClientAccountSubscriberV2.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,6 @@ export class WebSocketDriftClientAccountSubscriberV2
132132
this.subscriptionPromiseResolver = res;
133133
});
134134

135-
// Profile public key generation
136-
const pubkeyStartTime = performance.now();
137-
138135
const [perpMarketAccountPubkeys, spotMarketAccountPubkeys] =
139136
await Promise.all([
140137
Promise.all(
@@ -148,8 +145,6 @@ export class WebSocketDriftClientAccountSubscriberV2
148145
)
149146
),
150147
]);
151-
const pubkeyEndTime = performance.now();
152-
const pubkeyDuration = pubkeyEndTime - pubkeyStartTime;
153148

154149
// Profile findAllMarketsAndOracles if needed
155150
let findAllMarketsDuration = 0;
@@ -292,12 +287,7 @@ export class WebSocketDriftClientAccountSubscriberV2
292287
subscribeToOraclesEndTime - subscribeToOraclesStartTime;
293288
return duration;
294289
})(),
295-
(async () => {
296-
const stateFetchStartTime = performance.now();
297-
await this.stateAccountSubscriber.fetch();
298-
const stateFetchEndTime = performance.now();
299-
const stateFetchDuration = stateFetchEndTime - stateFetchStartTime;
300-
})(),
290+
this.stateAccountSubscriber.fetch(),
301291
]);
302292

303293
const initialPerpMarketDataFromLatestData = new Map(

sdk/src/driftClient.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,8 @@ import { getOracleId } from './oracles/oracleId';
192192
import { SignedMsgOrderParams } from './types';
193193
import { sha256 } from '@noble/hashes/sha256';
194194
import { getOracleConfidenceFromMMOracleData } from './oracles/utils';
195-
import { WebSocketDriftClientAccountSubscriberV2 } from './accounts/webSocketDriftClientAccountSubscriberV2';
196195
import { Commitment } from 'gill';
196+
import { WebSocketDriftClientAccountSubscriber } from '@drift-labs/sdk';
197197

198198
type RemainingAccountParams = {
199199
userAccounts: UserAccount[];
@@ -438,7 +438,10 @@ export class DriftClient {
438438
}
439439
);
440440
} else {
441-
this.accountSubscriber = new WebSocketDriftClientAccountSubscriberV2(
441+
const accountSubscriberClass =
442+
config.accountSubscription?.driftClientAccountSubscriber ??
443+
WebSocketDriftClientAccountSubscriber;
444+
this.accountSubscriber = new accountSubscriberClass(
442445
this.program,
443446
config.perpMarketIndexes ?? [],
444447
config.spotMarketIndexes ?? [],

0 commit comments

Comments
 (0)