txpool: smaller lock portion

This commit is contained in:
Martin Holst Swende 2019-09-16 15:08:45 +02:00
parent 8bd64f4a1c
commit 47fd824ebd
No known key found for this signature in database
GPG key ID: 683B438C05A5DDF0

View file

@ -803,18 +803,17 @@ func (pool *TxPool) addTxsLocked(txs []*types.Transaction, local bool) ([]error,
// Status returns the status (unknown/pending/queued) of a batch of transactions
// identified by their hashes.
func (pool *TxPool) Status(hashes []common.Hash) []TxStatus {
pool.mu.RLock()
defer pool.mu.RUnlock()
status := make([]TxStatus, len(hashes))
for i, hash := range hashes {
if tx := pool.all.Get(hash); tx != nil {
if tx := pool.Get(hash); tx != nil {
from, _ := types.Sender(pool.signer, tx) // already validated
if pool.pending[from] != nil && pool.pending[from].txs.items[tx.Nonce()] != nil {
pool.mu.RLock()
if txList := pool.pending[from]; txList != nil && txList.txs.items[tx.Nonce()] != nil {
status[i] = TxStatusPending
} else {
status[i] = TxStatusQueued
}
pool.mu.RUnlock()
}
}
return status