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 committed Feb 14, 2025
1 parent b7ba978 commit 17f039c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions core/types/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ func (t *Transaction) Hash() Hash {
return HashBytes(raw)
}

func (t *Transaction) String() string {
return fmt.Sprintf("Tx{Hash: %X, Sender: %X, Nonce: %d, PayloadType: %s}", t.Hash(), t.Sender, t.Body.Nonce, t.Body.PayloadType)
}

// TransactionBody is the body of a transaction that gets included in the
// signature. This type implements json.Marshaler and json.Unmarshaler to ensure
// that the Fee field is represented as a string in JSON rather than a number.
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 17f039c

Please sign in to comment.