From 47fd824ebd0295fd07835fd3600fdca545fd0e84 Mon Sep 17 00:00:00 2001 From: Martin Holst Swende Date: Mon, 16 Sep 2019 15:08:45 +0200 Subject: [PATCH] txpool: smaller lock portion --- core/tx_pool.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/core/tx_pool.go b/core/tx_pool.go index 161489cc5a..db63efbc98 100644 --- a/core/tx_pool.go +++ b/core/tx_pool.go @@ -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