Skip to content

Commit

Permalink
sdk: tweak polling tx confirmation (#812)
Browse files Browse the repository at this point in the history
* sdk: fix tests not building

* sdk: tweak polling tx confirmation
  • Loading branch information
crispheaney authored Jan 9, 2024
1 parent ef3f7ef commit b14e036
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 b14e036

Please sign in to comment.