From ebe0ff0a47829dd72135714e2157f8fcf1707c81 Mon Sep 17 00:00:00 2001 From: buddh0 Date: Thu, 25 Jan 2024 16:11:54 +0800 Subject: [PATCH] core/txpool: ignore nil sub when subpool have been shut down --- core/txpool/txpool.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/core/txpool/txpool.go b/core/txpool/txpool.go index d03e025a9e..104272f532 100644 --- a/core/txpool/txpool.go +++ b/core/txpool/txpool.go @@ -366,9 +366,12 @@ func (p *TxPool) Pending(enforceTips bool) map[common.Address][]*LazyTransaction // SubscribeTransactions registers a subscription for new transaction events, // supporting feeding only newly seen or also resurrected transactions. func (p *TxPool) SubscribeTransactions(ch chan<- core.NewTxsEvent, reorgs bool) event.Subscription { - subs := make([]event.Subscription, len(p.subpools)) - for i, subpool := range p.subpools { - subs[i] = subpool.SubscribeTransactions(ch, reorgs) + subs := make([]event.Subscription, 0, len(p.subpools)) + for _, subpool := range p.subpools { + sub := subpool.SubscribeTransactions(ch, reorgs) + if sub != nil { // sub will be nil when subpool have been shut down + subs = append(subs, sub) + } } return p.subs.Track(event.JoinSubscriptions(subs...)) }