Skip to content

Commit

Permalink
concurrency access on the mempool from txquery and recheckTxs
Browse files Browse the repository at this point in the history
  • Loading branch information
charithabandi authored and jchappelow committed Feb 14, 2025
1 parent b7ba978 commit 43f307c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
2 changes: 1 addition & 1 deletion node/block_processor/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ func (bp *BlockProcessor) CheckTx(ctx context.Context, tx *ktypes.Transaction, h
Authenticator: tx.Signature.Type,
}, readTx, tx)
if err != nil {
bp.log.Info("Transaction rejected", "tx", txHash, "err", err)
bp.log.Info("Transaction rejected", "tx", txHash, "err", err, "recheck", recheck)
return err
}

Expand Down
6 changes: 1 addition & 5 deletions node/consensus/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,7 @@ func (ce *ConsensusEngine) recheckTx(ctx context.Context, tx *ktypes.Transaction
}
ce.stateInfo.mtx.RUnlock()

err := ce.blockProcessor.CheckTx(ctx, tx, height, timestamp, true)
if err != nil {
ce.log.Infof("recheckTx failed for tx %s, err: %s", tx, err)
}
return err
return ce.blockProcessor.CheckTx(ctx, tx, height, timestamp, true)
}

// BroadcastTx checks the Tx with the mempool and if the verification is successful, broadcasts the Tx to the network.
Expand Down
4 changes: 2 additions & 2 deletions node/mempool/mempool.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,8 @@ type CheckFn func(ctx context.Context, tx *ktypes.Transaction) error
// RecheckTxs validates all transactions in the mempool using the provided check function,
// removing any that fail validation.
func (mp *Mempool) RecheckTxs(ctx context.Context, fn CheckFn) {
mp.mtx.RLock()
defer mp.mtx.RUnlock()
mp.mtx.Lock()
defer mp.mtx.Unlock()

for hash, tx := range mp.txns {
if err := fn(ctx, tx.Transaction); err != nil {
Expand Down

0 comments on commit 43f307c

Please sign in to comment.