Skip to content

Commit

Permalink
sdk: tweak polling tx confirmation
Browse files Browse the repository at this point in the history
  • Loading branch information
crispheaney committed Jan 8, 2024
1 parent 4d249c7 commit 7645c5b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions sdk/src/tx/baseTxSender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,17 +247,18 @@ export abstract class BaseTxSender implements TxSender {
commitment: Commitment = 'finalized'
): Promise<RpcResponseAndContext<SignatureResult> | undefined> {
let totalTime = 0;
let backoffTime = 250;
let backoffTime = 400; // approx block time

while (totalTime < this.timeout) {
await new Promise((resolve) => setTimeout(resolve, backoffTime));

const response = await this.connection.getSignatureStatus(signature);
const result = response && response.value?.[0];

if (result && result.confirmationStatus === commitment) {
return { context: result.context, value: { err: null } };
}

await new Promise((resolve) => setTimeout(resolve, backoffTime));
totalTime += backoffTime;
backoffTime = Math.min(backoffTime * 2, 5000);
}
Expand Down

0 comments on commit 7645c5b

Please sign in to comment.