From 676b07cd23be050c1a04891e86b500d8d13d4eb0 Mon Sep 17 00:00:00 2001 From: James Walker Date: Wed, 24 Jan 2024 17:43:06 -0500 Subject: [PATCH] address comments --- common/txmgr/strategies.go | 2 +- common/txmgr/txmgr.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/common/txmgr/strategies.go b/common/txmgr/strategies.go index 2fff3b7febc..3772e6d1d20 100644 --- a/common/txmgr/strategies.go +++ b/common/txmgr/strategies.go @@ -61,7 +61,7 @@ func (s DropOldestStrategy) PruneQueue(ctx context.Context, pruneService txmgrty ctx, cancel = context.WithTimeout(ctx, s.queryTimeout) defer cancel() - // NOTE: We prune one less than the queue size because we will be adding a new transaction to the queue right after this PruneQueue call + // NOTE: We prune one less than the queue size to prevent the queue from exceeding the max queue size. Which could occur if a new transaction is added to the queue right after we prune. ids, err = pruneService.PruneUnstartedTxQueue(ctx, s.queueSize-1, s.subject) if err != nil { return ids, fmt.Errorf("DropOldestStrategy#PruneQueue failed: %w", err) diff --git a/common/txmgr/txmgr.go b/common/txmgr/txmgr.go index bc4cc02e1f8..583ee217d2f 100644 --- a/common/txmgr/txmgr.go +++ b/common/txmgr/txmgr.go @@ -522,7 +522,7 @@ func (b *Txm[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) CreateTran return tx, fmt.Errorf("Txm#CreateTransaction: %w", err) } - tx, err = b.createTxnAndPruneQueue(ctx, txRequest, b.chainID) + tx, err = b.pruneQueueAndCreateTxn(ctx, txRequest, b.chainID) if err != nil { return tx, err } @@ -562,7 +562,7 @@ func (b *Txm[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) SendNative FeeLimit: gasLimit, Strategy: NewSendEveryStrategy(), } - etx, err = b.createTxnAndPruneQueue(ctx, txRequest, chainID) + etx, err = b.pruneQueueAndCreateTxn(ctx, txRequest, chainID) if err != nil { return etx, fmt.Errorf("SendNativeToken failed to insert tx: %w", err) } @@ -683,7 +683,7 @@ func (n *NullTxManager[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]) Cou return count, errors.New(n.ErrMsg) } -func (b *Txm[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) createTxnAndPruneQueue( +func (b *Txm[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) pruneQueueAndCreateTxn( ctx context.Context, txRequest txmgrtypes.TxRequest[ADDR, TX_HASH], chainID CHAIN_ID,