mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-19 13:21:37 +00:00
This commit is contained in:
parent
129b1c877b
commit
cd5ce5ae48
3 changed files with 13 additions and 4 deletions
|
|
@ -1505,7 +1505,7 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals bool) (int, []
|
|||
}
|
||||
|
||||
// Start a parallel signature recovery (signer will fluke on fork transition, minimal perf loss)
|
||||
SenderCacher.RecoverFromBlocks(types.MakeSigner(bc.chainConfig, chain[0].Number()), chain)
|
||||
SenderCacher().RecoverFromBlocks(types.MakeSigner(bc.chainConfig, chain[0].Number()), chain)
|
||||
|
||||
// A queued approach to delivering events. This is generally
|
||||
// faster than direct delivery and requires much less mutex
|
||||
|
|
|
|||
|
|
@ -18,12 +18,21 @@ package core
|
|||
|
||||
import (
|
||||
"runtime"
|
||||
"sync"
|
||||
|
||||
"github.com/XinFinOrg/XDPoSChain/core/types"
|
||||
)
|
||||
|
||||
// SenderCacher is a concurrent transaction sender recoverer and cacher.
|
||||
var SenderCacher = newTxSenderCacher(runtime.NumCPU())
|
||||
// senderCacherOnce is used to ensure that the SenderCacher is initialized only once.
|
||||
var senderCacherOnce = sync.OnceValue(func() *txSenderCacher {
|
||||
return newTxSenderCacher(runtime.NumCPU())
|
||||
})
|
||||
|
||||
// SenderCacher returns the singleton instance of SenderCacher, initializing it if called for the first time.
|
||||
// This function is thread-safe and ensures that initialization happens only once.
|
||||
func SenderCacher() *txSenderCacher {
|
||||
return senderCacherOnce()
|
||||
}
|
||||
|
||||
// txSenderCacherRequest is a request for recovering transaction senders with a
|
||||
// specific signature scheme and caching it into the transactions themselves.
|
||||
|
|
|
|||
|
|
@ -1635,7 +1635,7 @@ func (pool *LegacyPool) reset(oldHead, newHead *types.Header) {
|
|||
|
||||
// Inject any transactions discarded due to reorgs
|
||||
log.Debug("Reinjecting stale transactions", "count", len(reinject))
|
||||
core.SenderCacher.Recover(pool.signer, reinject)
|
||||
core.SenderCacher().Recover(pool.signer, reinject)
|
||||
pool.addTxsLocked(reinject, false)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue