Skip to content

Commit

Permalink
fix cached id data race
Browse files Browse the repository at this point in the history
  • Loading branch information
algorandskiy committed Sep 20, 2024
1 parent 2e055ca commit 5759b58
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions data/txHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,10 @@ func (handler *TxHandler) backlogWorker() {
logging.Base().Warnf("Failed to release capacity to ElasticRateLimiter: %v", err)
}
}
// precompute transaction IDs
for i := range wi.unverifiedTxGroup {
wi.unverifiedTxGroup[i].CacheID()
}
if handler.checkAlreadyCommitted(wi) {
transactionMessagesAlreadyCommitted.Inc(nil)
if wi.capguard != nil {
Expand Down Expand Up @@ -531,11 +535,6 @@ func (handler *TxHandler) postProcessCheckedTxn(wi *txBacklogMsg) {
// at this point, we've verified the transaction, so we can safely treat the transaction as a verified transaction.
verifiedTxGroup := wi.unverifiedTxGroup

// precompute transaction IDs
for i := range verifiedTxGroup {
verifiedTxGroup[i].CacheID()
}

// save the transaction, if it has high enough fee and not already in the cache
err := handler.txPool.Remember(verifiedTxGroup)
if err != nil {
Expand Down

0 comments on commit 5759b58

Please sign in to comment.