Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

txpool: fix a potential crash issue in shutdown; #1951

Merged
merged 1 commit into from
Oct 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions core/txpool/txpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,11 +319,11 @@ func (p *TxPool) Pending(enforceTips bool) map[common.Address][]*LazyTransaction
// SubscribeNewTxsEvent registers a subscription of NewTxsEvent and starts sending
// events to the given channel.
func (p *TxPool) SubscribeNewTxsEvent(ch chan<- core.NewTxsEvent) event.Subscription {
subs := make([]event.Subscription, len(p.subpools))
for i, subpool := range p.subpools {
subs := make([]event.Subscription, 0, len(p.subpools))
for _, subpool := range p.subpools {
sub := subpool.SubscribeTransactions(ch)
if sub != nil { // sub will be nil when subpool have been shut down
subs[i] = sub
subs = append(subs, sub)
}
}
return p.subs.Track(event.JoinSubscriptions(subs...))
Expand All @@ -332,11 +332,11 @@ func (p *TxPool) SubscribeNewTxsEvent(ch chan<- core.NewTxsEvent) event.Subscrip
// SubscribeNewTxsEvent registers a subscription of NewTxsEvent and starts sending
// events to the given channel.
func (p *TxPool) SubscribeReannoTxsEvent(ch chan<- core.ReannoTxsEvent) event.Subscription {
subs := make([]event.Subscription, len(p.subpools))
for i, subpool := range p.subpools {
subs := make([]event.Subscription, 0, len(p.subpools))
for _, subpool := range p.subpools {
sub := subpool.SubscribeReannoTxsEvent(ch)
if sub != nil { // sub will be nil when subpool have been shut down
subs[i] = sub
subs = append(subs, sub)
}
}
return p.subs.Track(event.JoinSubscriptions(subs...))
Expand Down