mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
refactor(tx_pool.go): caching signature check result before holding lock significantly improve concurrency
This commit is contained in:
parent
5f251a6448
commit
7f151ff133
1 changed files with 8 additions and 0 deletions
|
|
@ -798,6 +798,9 @@ func (pool *TxPool) AddRemotes(txs []*types.Transaction) []error {
|
|||
|
||||
// addTx enqueues a single transaction into the pool if it is valid.
|
||||
func (pool *TxPool) addTx(tx *types.Transaction, local bool) error {
|
||||
// caching signature check result before holding lock significantly improve concurrency
|
||||
types.Sender(pool.signer, tx)
|
||||
|
||||
pool.mu.Lock()
|
||||
defer pool.mu.Unlock()
|
||||
|
||||
|
|
@ -816,6 +819,11 @@ func (pool *TxPool) addTx(tx *types.Transaction, local bool) error {
|
|||
|
||||
// addTxs attempts to queue a batch of transactions if they are valid.
|
||||
func (pool *TxPool) addTxs(txs []*types.Transaction, local bool) []error {
|
||||
// caching signature check result before holding lock significantly improve concurrency
|
||||
for _, tx := range txs {
|
||||
types.Sender(pool.signer, tx)
|
||||
}
|
||||
|
||||
pool.mu.Lock()
|
||||
defer pool.mu.Unlock()
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue