Skip to content

Commit

Permalink
improve timing defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
abrzezinski94 committed Jan 15, 2024
1 parent 111a456 commit 6a13044
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@blockworks-foundation/mangolana",
"version": "0.0.5",
"version": "0.0.6",
"description": "",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down
8 changes: 4 additions & 4 deletions src/globalTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ export interface TimeoutStrategy {

/**
* @param timeout optional (secs) after how much secs not confirmed transaction will be considered timeout, default: 90
* @param getSignatureStatusesPoolIntervalMs optional (ms) pool interval of getSignatureStatues, default: 2000
* @param getSignatureStatusesPoolIntervalMs optional (ms) pool interval of getSignatureStatues, default: 4000
*/
export interface Time {
timeout: number;
}
/**
* @param startBlockCheckAfterSecs optional (secs) after that time we will start to pool current blockheight and check if transaction will reach blockchain, default: 90
* @param block BlockhashWithExpiryBlockHeight
* @param getSignatureStatusesPoolIntervalMs optional (ms) pool interval of getSignatureStatues and blockheight, default: 2000
* @param getSignatureStatusesPoolIntervalMs optional (ms) pool interval of getSignatureStatues and blockheight, default: 4000
*/
export interface BlockHeight {
startBlockCheckAfterSecs?: number;
Expand All @@ -42,7 +42,7 @@ export class TimeStrategyClass implements TimeStrategy {
getSignatureStatusesPoolIntervalMs: number;
constructor({
timeout = 90,
getSignatureStatusesPoolIntervalMs = 5000,
getSignatureStatusesPoolIntervalMs = 4000,
}: {
timeout: number;
getSignatureStatusesPoolIntervalMs?: number;
Expand All @@ -58,7 +58,7 @@ export class BlockHeightStrategyClass implements BlockHeightStrategy {
constructor({
startBlockCheckAfterSecs = 10,
block,
getSignatureStatusesPoolIntervalMs = 5000,
getSignatureStatusesPoolIntervalMs = 4000,
}: {
block: BlockhashWithExpiryBlockHeight;
getSignatureStatusesPoolIntervalMs?: number;
Expand Down
16 changes: 8 additions & 8 deletions src/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ export type awaitTransactionSignatureConfirmationProps = {
* TimeStrategy: pure timeout strategy
*
* timeout: optional, (secs) after how much secs not confirmed transaction will be considered timeout, default: 90
* getSignatureStatusesPoolIntervalMs: optional, (ms) pool interval of getSignatureStatues, default: 2000
* getSignatureStatusesPoolIntervalMs: optional, (ms) pool interval of getSignatureStatues, default: 4000
*
*
* BlockHeightStrategy: blockheight pool satrategy
*
* startBlockCheckAfterSecs: optional, (secs) after that time we will start to pool current blockheight and check if transaction will reach blockchain, default: 90
* block: BlockhashWithExpiryBlockHeight
* getSignatureStatusesPoolIntervalMs: optional, (ms) pool interval of getSignatureStatues and blockheight, default: 2000
* getSignatureStatusesPoolIntervalMs: optional, (ms) pool interval of getSignatureStatues and blockheight, default: 4000
* @param config.logFlowInfo when true it will console log process of processing transactions
*/
export const awaitTransactionSignatureConfirmation = async ({
Expand Down Expand Up @@ -118,7 +118,7 @@ const confirmWithSignatureStatuses = (
return new Promise<RpcResponseAndContext<SignatureStatus>>(async (resolve, reject) => {
try {
let intervalTimeout: NodeJS.Timer | null = null;
const retryTimer = timeoutConfig.getSignatureStatusesPoolIntervalMs || 5000;
const retryTimer = timeoutConfig.getSignatureStatusesPoolIntervalMs || 4000;
const onAbort = () => {
if (intervalTimeout) {
clearInterval(intervalTimeout);
Expand Down Expand Up @@ -244,7 +244,7 @@ const timeoutCheck = (
};
internalSignal.addEventListener('abort', onAbort);
externalSignal?.addEventListener('abort', onAbort);
const retrySleep = timeoutConfig.getSignatureStatusesPoolIntervalMs || 5000;
const retrySleep = timeoutConfig.getSignatureStatusesPoolIntervalMs || 4000;
setTimeoutTimer = setTimeout(async () => {
try {
if (timeoutBlockHeight !== 0) {
Expand Down Expand Up @@ -303,17 +303,17 @@ export type sendAndConfirmSignedTransactionProps = {
* TimeStrategy: pure timeout strategy
*
* timeout: optional, (secs) after how much secs not confirmed transaction will be considered timeout, default: 90
* getSignatureStatusesPoolIntervalMs: optional, (ms) pool interval of getSignatureStatues, default: 5000
* getSignatureStatusesPoolIntervalMs: optional, (ms) pool interval of getSignatureStatues, default: 4000
*
*
* BlockHeightStrategy: blockheight pool satrategy
*
* startBlockCheckAfterSecs: optional, (secs) after that time we will start to pool current blockheight and check if transaction will reach blockchain, default: 90
* block: BlockhashWithExpiryBlockHeight
* getSignatureStatusesPoolIntervalMs: optional, (ms) pool interval of getSignatureStatues and blockheight, default: 2000
* getSignatureStatusesPoolIntervalMs: optional, (ms) pool interval of getSignatureStatues and blockheight, default: 4000
*
* @param config.resendTxUntilConfirmed force resend transaction in the mean time of waiting for confirmation, default false
* @param config.resendPoolTimeMs when resendTxUntilConfirmed is true it will resend transaction every value of ms until there is timeout, default 2000
* @param config.resendPoolTimeMs when resendTxUntilConfirmed is true it will resend transaction every value of ms until there is timeout, default: 2000
* @param config.logFlowInfo when true it will console log process of processing transactions
* @param config.skipPreflight
*/
Expand Down Expand Up @@ -442,7 +442,7 @@ export type sendSignAndConfirmTransactionsProps = {
*
* startBlockCheckAfterSecs: optional, (secs) after that time we will start to pool current blockheight and check if transaction will reach blockchain, default: 90
* block: BlockhashWithExpiryBlockHeight
* getSignatureStatusesPoolIntervalMs: optional, (ms) pool interval of getSignatureStatues and blockheight, default: 2000
* getSignatureStatusesPoolIntervalMs: optional, (ms) pool interval of getSignatureStatues and blockheight, default: 4000
*
*
* @param callbacks sets of callbacks
Expand Down

0 comments on commit 6a13044

Please sign in to comment.