Skip to content

Commit

Permalink
use undefined guards
Browse files Browse the repository at this point in the history
  • Loading branch information
NourAlharithi committed Nov 21, 2024
1 parent 38dce24 commit 9d13a63
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions sdk/src/driftClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -445,15 +445,16 @@ export class DriftClient {
this.sbOnDemandProgramdId =
configs[config.env ?? 'mainnet-beta'].SB_ON_DEMAND_PID;

this.connectionRotationSlotTimeoutThreshold =
config.connectionRotationConfig.rotationTimeoutMs || 10_000;
if (this.connectionRotationSlotTimeoutThreshold < 0) {
throw new Error(
'connectionRotationSlotTimeoutThreshold should be at least 10_000ms to avoid spamming connection resub'
);
}
const backupConnections = config.connectionRotationConfig.backupConnections;
const backupConnections = config.connectionRotationConfig?.backupConnections;
if (backupConnections?.length > 0) {
this.connectionRotationSlotTimeoutThreshold =
config.connectionRotationConfig?.rotationTimeoutMs || 10_000;
if (this.connectionRotationSlotTimeoutThreshold < 10_000) {
throw new Error(
'connectionRotationSlotTimeoutThreshold should be at least 10_000ms to avoid spamming connection resub'
);
}

this.allConnections = [this.connection, ...backupConnections];
}
}
Expand Down

0 comments on commit 9d13a63

Please sign in to comment.