mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
core/txpool: ignore nil sub when subpool have been shut down
This commit is contained in:
parent
99dc3fe118
commit
ebe0ff0a47
1 changed files with 6 additions and 3 deletions
|
|
@ -366,9 +366,12 @@ func (p *TxPool) Pending(enforceTips bool) map[common.Address][]*LazyTransaction
|
||||||
// SubscribeTransactions registers a subscription for new transaction events,
|
// SubscribeTransactions registers a subscription for new transaction events,
|
||||||
// supporting feeding only newly seen or also resurrected transactions.
|
// supporting feeding only newly seen or also resurrected transactions.
|
||||||
func (p *TxPool) SubscribeTransactions(ch chan<- core.NewTxsEvent, reorgs bool) event.Subscription {
|
func (p *TxPool) SubscribeTransactions(ch chan<- core.NewTxsEvent, reorgs bool) event.Subscription {
|
||||||
subs := make([]event.Subscription, len(p.subpools))
|
subs := make([]event.Subscription, 0, len(p.subpools))
|
||||||
for i, subpool := range p.subpools {
|
for _, subpool := range p.subpools {
|
||||||
subs[i] = subpool.SubscribeTransactions(ch, reorgs)
|
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...))
|
return p.subs.Track(event.JoinSubscriptions(subs...))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue