Skip to content

Commit

Permalink
Removed attempts cache population check
Browse files Browse the repository at this point in the history
  • Loading branch information
amit-momin committed Jan 30, 2025
1 parent 8e2542c commit 0c797e3
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions core/chains/evm/txmgr/finalizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ type evmFinalizer struct {
resumeCallback resumeCallback

attemptsCache []TxAttempt
attemptsCacheMu sync.Mutex
attemptsCacheHitCount int
}

Expand All @@ -132,6 +131,7 @@ func NewEvmFinalizer(
headTracker: headTracker,
mb: mailbox.NewSingle[*types.Head](),
resumeCallback: nil,
attemptsCacheHitCount: attemptsCacheRefreshThreshold, // start hit count at threshold to refresh cache on first run
}
}

Expand Down Expand Up @@ -680,10 +680,8 @@ func (f *evmFinalizer) buildTxHashList(finalizedReceipts []*types.Receipt) []com
// Attempts are cached and used for subsequent fetches to reduce the load of the query.
// The attempts cache is refreshed every 3 requests.
func (f *evmFinalizer) fetchAttemptsRequiringReceiptFetch(ctx context.Context) ([]TxAttempt, error) {
f.attemptsCacheMu.Lock()
defer f.attemptsCacheMu.Unlock()
// Return attempts from attempts cache if it is populated and the hit count has not reached the threshold for refresh
if len(f.attemptsCache) != 0 && f.attemptsCacheHitCount < attemptsCacheRefreshThreshold {
if f.attemptsCacheHitCount < attemptsCacheRefreshThreshold {
f.attemptsCacheHitCount++
return f.attemptsCache, nil
}
Expand All @@ -700,8 +698,6 @@ func (f *evmFinalizer) fetchAttemptsRequiringReceiptFetch(ctx context.Context) (

// filterAttemptsCache removes attempts from the cache if a receipt was found for their transaction's ID
func (f *evmFinalizer) filterAttemptsCache(receipts []*types.Receipt) {
f.attemptsCacheMu.Lock()
defer f.attemptsCacheMu.Unlock()
// Skip method if no receipts found
if len(receipts) == 0 {
return
Expand Down

0 comments on commit 0c797e3

Please sign in to comment.