fix(core/txpool): avoid blocking reset completion on close #31030 (#2175)

* fix(core/txpool): coordinate reset lifecycle and shutdown signaling #28837

Improve txpool loop synchronization around background resets.

This change:
- adds an explicit termination channel to signal pool shutdown
- tracks forced-reset intent and a waiter channel inside the reset loop
- ensures reset waiters are notified on completion or on pool termination
- allows an explicit sync request path to trigger an additional reset round when needed

Scope is limited to internal txpool concurrency control in core/txpool/txpool.go, with no protocol or RPC behavior change.

* fix(core/txpool): avoid blocking reset completion on close #31030
This commit is contained in:
Daniel Liu 2026-03-17 14:32:17 +08:00 committed by GitHub
parent 5625cf6f6e
commit 6f02401575
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -166,7 +166,10 @@ func (p *TxPool) loop(head *types.Header, chain BlockChain) {
for _, subpool := range p.subpools {
subpool.Reset(oldHead, newHead)
}
resetDone <- newHead
select {
case resetDone <- newHead:
case <-p.term:
}
}(oldHead, newHead)
// If the reset operation was explicitly requested, consider it