core/txpool: notify sync waiter if txpool is closed

This commit is contained in:
Gary Rong 2024-01-23 21:59:38 +08:00 committed by Martin Holst Swende
parent 86d17787ce
commit 3a73fb6cbf
No known key found for this signature in database
GPG key ID: 683B438C05A5DDF0

View file

@ -202,6 +202,13 @@ func (p *TxPool) loop(head *types.Header, chain BlockChain) {
resetForced bool // Whether a forced reset was requested, only used in simulator mode resetForced bool // Whether a forced reset was requested, only used in simulator mode
resetWaiter chan error // Channel waiting on a forced reset, only used in simulator mode resetWaiter chan error // Channel waiting on a forced reset, only used in simulator mode
) )
// Notify the live reset waiter to not block if the txpool is closed.
defer func() {
if resetWaiter != nil {
resetWaiter <- errors.New("pool already terminated")
resetWaiter = nil
}
}()
var errc chan error var errc chan error
for errc == nil { for errc == nil {
// Something interesting might have happened, run a reset if there is // Something interesting might have happened, run a reset if there is