feat: make confirm transaction timeout configurable (#19954)

This commit is contained in:
Josh 2021-09-17 09:54:25 -07:00 committed by GitHub
parent 9998e16df3
commit 0404e75e96
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 2 deletions

View File

@ -1979,6 +1979,8 @@ export type ConnectionConfig = {
fetchMiddleware?: FetchMiddleware;
/** Optional Disable retring calls when server responds with HTTP 429 (Too Many Requests) */
disableRetryOnRateLimit?: boolean;
/** time to allow for the server to initially process a transaction (in milliseconds) */
confirmTransactionInitialTimeout?: number;
};
/**
@ -1986,6 +1988,7 @@ export type ConnectionConfig = {
*/
export class Connection {
/** @internal */ _commitment?: Commitment;
/** @internal */ _confirmTransactionInitialTimeout?: number;
/** @internal */ _rpcEndpoint: string;
/** @internal */ _rpcWsEndpoint: string;
/** @internal */ _rpcClient: RpcClient;
@ -2070,6 +2073,8 @@ export class Connection {
this._commitment = commitmentOrConfig;
} else if (commitmentOrConfig) {
this._commitment = commitmentOrConfig.commitment;
this._confirmTransactionInitialTimeout =
commitmentOrConfig.confirmTransactionInitialTimeout;
wsEndpoint = commitmentOrConfig.wsEndpoint;
httpHeaders = commitmentOrConfig.httpHeaders;
fetchMiddleware = commitmentOrConfig.fetchMiddleware;
@ -2629,14 +2634,14 @@ export class Connection {
}
});
let timeoutMs = 60 * 1000;
let timeoutMs = this._confirmTransactionInitialTimeout || 60 * 1000;
switch (subscriptionCommitment) {
case 'processed':
case 'recent':
case 'single':
case 'confirmed':
case 'singleGossip': {
timeoutMs = 30 * 1000;
timeoutMs = this._confirmTransactionInitialTimeout || 30 * 1000;
break;
}
// exhaust enums to ensure full coverage