Skip to content

Commit

Permalink
Adjust logging.
Browse files Browse the repository at this point in the history
  • Loading branch information
andreibancioiu committed Nov 6, 2024
1 parent 09f30ed commit 9e31b00
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
1 change: 0 additions & 1 deletion txcache/txCache.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,6 @@ func (cache *TxCache) NotifyAccountNonce(accountKey []byte, nonce uint64) {
evicted := cache.txListBySender.notifyAccountNonceReturnEvictedTransactions(accountKey, nonce)

if len(evicted) > 0 {
logRemove.Trace("NotifyAccountNonce with eviction", "sender", accountKey, "nonce", nonce, "num evicted txs", len(evicted))
cache.txByHash.RemoveTxsBulk(evicted)
}
}
Expand Down
9 changes: 7 additions & 2 deletions txcache/txListForSender.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,9 @@ func (listForSender *txListForSender) countTxWithLock() uint64 {

// notifyAccountNonceReturnEvictedTransactions sets the known account nonce, removes the transactions with lower nonces, and returns their hashes
func (listForSender *txListForSender) notifyAccountNonceReturnEvictedTransactions(nonce uint64) [][]byte {
// Optimization: if nonce is the same, do nothing.
// Optimization: if nonce is the same, do nothing (good for heavy load).
if listForSender.accountNonce.Get() == nonce {
logRemove.Trace("notifyAccountNonceReturnEvictedTransactions, nonce is the same", "sender", listForSender.sender, "nonce", nonce)
return nil
}

Expand All @@ -270,7 +271,11 @@ func (listForSender *txListForSender) notifyAccountNonceReturnEvictedTransaction
listForSender.accountNonce.Set(nonce)
_ = listForSender.accountNonceKnown.SetReturningPrevious()

return listForSender.evictTransactionsWithLowerNoncesNoLockReturnEvicted(nonce)
evicted := listForSender.evictTransactionsWithLowerNoncesNoLockReturnEvicted(nonce)

logRemove.Trace("notifyAccountNonceReturnEvictedTransactions, nonce changed", "sender", listForSender.sender, "nonce", nonce, "num evicted txs", len(evicted))

return evicted
}

// This function should only be used in critical section (listForSender.mutex)
Expand Down

0 comments on commit 9e31b00

Please sign in to comment.