From 3a73fb6cbfcbb3523ed17b6b4bdfbf58856dcb99 Mon Sep 17 00:00:00 2001 From: Gary Rong Date: Tue, 23 Jan 2024 21:59:38 +0800 Subject: [PATCH] core/txpool: notify sync waiter if txpool is closed --- core/txpool/txpool.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core/txpool/txpool.go b/core/txpool/txpool.go index 7ec9dbebda1d..d03e025a9e6c 100644 --- a/core/txpool/txpool.go +++ b/core/txpool/txpool.go @@ -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 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 for errc == nil { // Something interesting might have happened, run a reset if there is