core: more efficient nonce-update in txpool (#22231)

* Adjust pending nonce update operation

Benchmark the speed of transaction insertion under multiple accounts

core: fix rebase issues + docstring

core: make benchmark test use sync:ed method

* core: address review comments

* core: add memreport to benchmark

Co-authored-by: WeiLoy <wei_loy@163.com>
This commit is contained in:
Martin Holst Swende
2021-11-02 18:32:23 +01:00
committed by GitHub
parent f49e90e32c
commit 03bc8b7858
3 changed files with 36 additions and 5 deletions

View File

@ -77,3 +77,11 @@ func (txn *txNoncer) setIfLower(addr common.Address, nonce uint64) {
}
txn.nonces[addr] = nonce
}
// setAll sets the nonces for all accounts to the given map.
func (txn *txNoncer) setAll(all map[common.Address]uint64) {
txn.lock.Lock()
defer txn.lock.Unlock()
txn.nonces = all
}