File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -368,6 +368,9 @@ func (self *TxPool) AddTransactions(txs []*types.Transaction) {
368
368
// GetTransaction returns a transaction if it is contained in the pool
369
369
// and nil otherwise.
370
370
func (tp * TxPool ) GetTransaction (hash common.Hash ) * types.Transaction {
371
+ tp .mu .RLock ()
372
+ defer tp .mu .RUnlock ()
373
+
371
374
// check the txs first
372
375
if tx , ok := tp .pending [hash ]; ok {
373
376
return tx
@@ -421,12 +424,18 @@ func (self *TxPool) RemoveTransactions(txs types.Transactions) {
421
424
self .mu .Lock ()
422
425
defer self .mu .Unlock ()
423
426
for _ , tx := range txs {
424
- self .RemoveTx (tx .Hash ())
427
+ self .removeTx (tx .Hash ())
425
428
}
426
429
}
427
430
428
431
// RemoveTx removes the transaction with the given hash from the pool.
429
432
func (pool * TxPool ) RemoveTx (hash common.Hash ) {
433
+ pool .mu .Lock ()
434
+ defer pool .mu .Unlock ()
435
+ pool .removeTx (hash )
436
+ }
437
+
438
+ func (pool * TxPool ) removeTx (hash common.Hash ) {
430
439
// delete from pending pool
431
440
delete (pool .pending , hash )
432
441
// delete from queue
You can’t perform that action at this time.
0 commit comments