Skip to content

Commit

Permalink
chore: move checkBlockHeight into block where it's used
Browse files Browse the repository at this point in the history
  • Loading branch information
steveluscher committed Jul 2, 2022
1 parent 6f6e517 commit 627d91f
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions web3.js/src/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3051,15 +3051,6 @@ export class Connection {
}
});

const checkBlockHeight = async () => {
try {
const blockHeight = await this.getBlockHeight(commitment);
return blockHeight;
} catch (_e) {
return -1;
}
};

const expiryPromise = new Promise<
| {__type: TransactionStatus.BLOCKHEIGHT_EXCEEDED}
| {__type: TransactionStatus.TIMED_OUT; timeoutMs: number}
Expand Down Expand Up @@ -3088,6 +3079,14 @@ export class Connection {
} else {
let config =
strategy as BlockheightBasedTransactionConfirmationStrategy;
const checkBlockHeight = async () => {
try {
const blockHeight = await this.getBlockHeight(commitment);
return blockHeight;
} catch (_e) {
return -1;
}
};
(async () => {
let currentBlockHeight = await checkBlockHeight();
if (done) return;
Expand Down

0 comments on commit 627d91f

Please sign in to comment.