mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-16 18:00:46 +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()
|
rpcSub := notifier.CreateSubscription()
|
||||||
|
|
||||||
|
txs := make(chan []*types.Transaction, 128)
|
||||||
|
pendingTxSub := api.events.SubscribePendingTxs(txs)
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
txs := make(chan []*types.Transaction, 128)
|
|
||||||
pendingTxSub := api.events.SubscribePendingTxs(txs)
|
|
||||||
defer pendingTxSub.Unsubscribe()
|
defer pendingTxSub.Unsubscribe()
|
||||||
|
|
||||||
chainConfig := api.sys.backend.ChainConfig()
|
chainConfig := api.sys.backend.ChainConfig()
|
||||||
|
|
@ -262,9 +263,10 @@ func (api *FilterAPI) NewHeads(ctx context.Context) (*rpc.Subscription, error) {
|
||||||
|
|
||||||
rpcSub := notifier.CreateSubscription()
|
rpcSub := notifier.CreateSubscription()
|
||||||
|
|
||||||
|
headers := make(chan *types.Header)
|
||||||
|
headersSub := api.events.SubscribeNewHeads(headers)
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
headers := make(chan *types.Header)
|
|
||||||
headersSub := api.events.SubscribeNewHeads(headers)
|
|
||||||
defer headersSub.Unsubscribe()
|
defer headersSub.Unsubscribe()
|
||||||
|
|
||||||
for {
|
for {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue