mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-17 13:36:37 +00:00
core/txpool: change lock in Pending method of legacy pool to read lock (#32924)
This PR makes a small update to the `Pending()` method in the legacy pool. By changing the lock from exclusive to read-only, it aims to improve concurrency performance. --------- Co-authored-by: rjl493456442 <garyrong0905@gmail.com>
This commit is contained in:
parent
ea1cf7bf5e
commit
c5598fe958
1 changed files with 4 additions and 4 deletions
|
|
@ -467,8 +467,8 @@ func (pool *LegacyPool) stats() (int, int) {
|
||||||
// Content retrieves the data content of the transaction pool, returning all the
|
// Content retrieves the data content of the transaction pool, returning all the
|
||||||
// pending as well as queued transactions, grouped by account and sorted by nonce.
|
// pending as well as queued transactions, grouped by account and sorted by nonce.
|
||||||
func (pool *LegacyPool) Content() (map[common.Address][]*types.Transaction, map[common.Address][]*types.Transaction) {
|
func (pool *LegacyPool) Content() (map[common.Address][]*types.Transaction, map[common.Address][]*types.Transaction) {
|
||||||
pool.mu.Lock()
|
pool.mu.RLock()
|
||||||
defer pool.mu.Unlock()
|
defer pool.mu.RUnlock()
|
||||||
|
|
||||||
pending := make(map[common.Address][]*types.Transaction, len(pool.pending))
|
pending := make(map[common.Address][]*types.Transaction, len(pool.pending))
|
||||||
for addr, list := range pool.pending {
|
for addr, list := range pool.pending {
|
||||||
|
|
@ -503,8 +503,8 @@ func (pool *LegacyPool) Pending(filter txpool.PendingFilter) (map[common.Address
|
||||||
if filter.BlobTxs {
|
if filter.BlobTxs {
|
||||||
return nil, 0
|
return nil, 0
|
||||||
}
|
}
|
||||||
pool.mu.Lock()
|
pool.mu.RLock()
|
||||||
defer pool.mu.Unlock()
|
defer pool.mu.RUnlock()
|
||||||
|
|
||||||
var count int
|
var count int
|
||||||
pending := make(map[common.Address][]*txpool.LazyTransaction, len(pool.pending))
|
pending := make(map[common.Address][]*txpool.LazyTransaction, len(pool.pending))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue