Skip to content

Commit

Permalink
core/txpool: ignore nil sub when subpool have been shut down (bnb-cha…
Browse files Browse the repository at this point in the history
…in#1915)

Co-authored-by: buddh0 <[email protected]>
  • Loading branch information
NathanBSC and buddh0 authored Oct 12, 2023
1 parent 73cfed0 commit b86459a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions core/txpool/txpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,10 @@ func (p *TxPool) Pending(enforceTips bool) map[common.Address][]*LazyTransaction
func (p *TxPool) SubscribeNewTxsEvent(ch chan<- core.NewTxsEvent) event.Subscription {
subs := make([]event.Subscription, len(p.subpools))
for i, subpool := range p.subpools {
subs[i] = subpool.SubscribeTransactions(ch)
sub := subpool.SubscribeTransactions(ch)
if sub != nil { // sub will be nil when subpool have been shut down
subs[i] = sub
}
}
return p.subs.Track(event.JoinSubscriptions(subs...))
}
Expand All @@ -331,7 +334,10 @@ func (p *TxPool) SubscribeNewTxsEvent(ch chan<- core.NewTxsEvent) event.Subscrip
func (p *TxPool) SubscribeReannoTxsEvent(ch chan<- core.ReannoTxsEvent) event.Subscription {
subs := make([]event.Subscription, len(p.subpools))
for i, subpool := range p.subpools {
subs[i] = subpool.SubscribeReannoTxsEvent(ch)
sub := subpool.SubscribeReannoTxsEvent(ch)
if sub != nil { // sub will be nil when subpool have been shut down
subs[i] = sub
}
}
return p.subs.Track(event.JoinSubscriptions(subs...))
}
Expand Down

0 comments on commit b86459a

Please sign in to comment.