mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-19 21:31:37 +00:00
eth/filters: fix race in NewPendingTransactions and NewHeads subscriptions
Co-authored-by: s1na <1591639+s1na@users.noreply.github.com>
This commit is contained in:
parent
3e0889571b
commit
58696fa2ae
1 changed files with 6 additions and 4 deletions
|
|
@ -189,9 +189,10 @@ func (api *FilterAPI) NewPendingTransactions(ctx context.Context, fullTx *bool)
|
|||
|
||||
rpcSub := notifier.CreateSubscription()
|
||||
|
||||
txs := make(chan []*types.Transaction, 128)
|
||||
pendingTxSub := api.events.SubscribePendingTxs(txs)
|
||||
|
||||
go func() {
|
||||
txs := make(chan []*types.Transaction, 128)
|
||||
pendingTxSub := api.events.SubscribePendingTxs(txs)
|
||||
defer pendingTxSub.Unsubscribe()
|
||||
|
||||
chainConfig := api.sys.backend.ChainConfig()
|
||||
|
|
@ -262,9 +263,10 @@ func (api *FilterAPI) NewHeads(ctx context.Context) (*rpc.Subscription, error) {
|
|||
|
||||
rpcSub := notifier.CreateSubscription()
|
||||
|
||||
headers := make(chan *types.Header)
|
||||
headersSub := api.events.SubscribeNewHeads(headers)
|
||||
|
||||
go func() {
|
||||
headers := make(chan *types.Header)
|
||||
headersSub := api.events.SubscribeNewHeads(headers)
|
||||
defer headersSub.Unsubscribe()
|
||||
|
||||
for {
|
||||
|
|
|
|||
Loading…
Reference in a new issue