mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
core/tx_pool: fix data race
This commit is contained in:
parent
47fd824ebd
commit
aab6a0b0ab
1 changed files with 13 additions and 9 deletions
|
|
@ -805,17 +805,21 @@ func (pool *TxPool) addTxsLocked(txs []*types.Transaction, local bool) ([]error,
|
|||
func (pool *TxPool) Status(hashes []common.Hash) []TxStatus {
|
||||
status := make([]TxStatus, len(hashes))
|
||||
for i, hash := range hashes {
|
||||
if tx := pool.Get(hash); tx != nil {
|
||||
tx := pool.Get(hash)
|
||||
if tx == nil {
|
||||
continue
|
||||
}
|
||||
from, _ := types.Sender(pool.signer, tx) // already validated
|
||||
pool.mu.RLock()
|
||||
if txList := pool.pending[from]; txList != nil && txList.txs.items[tx.Nonce()] != nil {
|
||||
status[i] = TxStatusPending
|
||||
} else {
|
||||
} else if txList := pool.queue[from]; txList != nil && txList.txs.items[tx.Nonce()] != nil {
|
||||
status[i] = TxStatusQueued
|
||||
}
|
||||
// implicit else: the tx may have been included into a block between
|
||||
// checking pool.Get and obtaining the lock. In that case, TxStatusUnknown is correct
|
||||
pool.mu.RUnlock()
|
||||
}
|
||||
}
|
||||
return status
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue