Skip to content

Commit

Permalink
Merge pull request #399 from j75689/fix/issue_388
Browse files Browse the repository at this point in the history
fix: nil pointer issue (#388)
  • Loading branch information
j75689 authored Sep 1, 2021
2 parents 3a8bf73 + 6e960cc commit 2d2740e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
9 changes: 6 additions & 3 deletions eth/filters/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,19 @@ func (api *PublicFilterAPI) NewPendingTransactionFilter() rpc.ID {
pendingTxs = make(chan []common.Hash)
pendingTxSub = api.events.SubscribePendingTxs(pendingTxs)
)
f := &filter{typ: PendingTransactionsSubscription, deadline: time.NewTimer(api.timeout), hashes: make([]common.Hash, 0), s: pendingTxSub}
api.filtersMu.Lock()
api.filters[pendingTxSub.ID] = f
api.filters[pendingTxSub.ID] = &filter{typ: PendingTransactionsSubscription, deadline: time.NewTimer(api.timeout), hashes: make([]common.Hash, 0), s: pendingTxSub}
api.filtersMu.Unlock()

gopool.Submit(func() {
for {
select {
case ph := <-pendingTxs:
f.hashes = append(f.hashes, ph...)
api.filtersMu.Lock()
if f, found := api.filters[pendingTxSub.ID]; found {
f.hashes = append(f.hashes, ph...)
}
api.filtersMu.Unlock()
case <-pendingTxSub.Err():
api.filtersMu.Lock()
delete(api.filters, pendingTxSub.ID)
Expand Down
11 changes: 0 additions & 11 deletions eth/filters/filter_system.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,17 +174,6 @@ func (sub *Subscription) Unsubscribe() {
// this ensures that the manager won't use the event channel which
// will probably be closed by the client asap after this method returns.
<-sub.Err()

drainLoop:
for {
select {
case <-sub.f.logs:
case <-sub.f.hashes:
case <-sub.f.headers:
default:
break drainLoop
}
}
})
}

Expand Down

0 comments on commit 2d2740e

Please sign in to comment.