|
|
@ -159,6 +159,8 @@ func (api *FilterAPI) NewPendingTransactions(ctx context.Context, fullTx *bool) |
|
|
|
go func() { |
|
|
|
go func() { |
|
|
|
txs := make(chan []*types.Transaction, 128) |
|
|
|
txs := make(chan []*types.Transaction, 128) |
|
|
|
pendingTxSub := api.events.SubscribePendingTxs(txs) |
|
|
|
pendingTxSub := api.events.SubscribePendingTxs(txs) |
|
|
|
|
|
|
|
defer pendingTxSub.Unsubscribe() |
|
|
|
|
|
|
|
|
|
|
|
chainConfig := api.sys.backend.ChainConfig() |
|
|
|
chainConfig := api.sys.backend.ChainConfig() |
|
|
|
|
|
|
|
|
|
|
|
for { |
|
|
|
for { |
|
|
@ -176,10 +178,8 @@ func (api *FilterAPI) NewPendingTransactions(ctx context.Context, fullTx *bool) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
case <-rpcSub.Err(): |
|
|
|
case <-rpcSub.Err(): |
|
|
|
pendingTxSub.Unsubscribe() |
|
|
|
|
|
|
|
return |
|
|
|
return |
|
|
|
case <-notifier.Closed(): |
|
|
|
case <-notifier.Closed(): |
|
|
|
pendingTxSub.Unsubscribe() |
|
|
|
|
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -233,16 +233,15 @@ func (api *FilterAPI) NewHeads(ctx context.Context) (*rpc.Subscription, error) { |
|
|
|
go func() { |
|
|
|
go func() { |
|
|
|
headers := make(chan *types.Header) |
|
|
|
headers := make(chan *types.Header) |
|
|
|
headersSub := api.events.SubscribeNewHeads(headers) |
|
|
|
headersSub := api.events.SubscribeNewHeads(headers) |
|
|
|
|
|
|
|
defer headersSub.Unsubscribe() |
|
|
|
|
|
|
|
|
|
|
|
for { |
|
|
|
for { |
|
|
|
select { |
|
|
|
select { |
|
|
|
case h := <-headers: |
|
|
|
case h := <-headers: |
|
|
|
notifier.Notify(rpcSub.ID, h) |
|
|
|
notifier.Notify(rpcSub.ID, h) |
|
|
|
case <-rpcSub.Err(): |
|
|
|
case <-rpcSub.Err(): |
|
|
|
headersSub.Unsubscribe() |
|
|
|
|
|
|
|
return |
|
|
|
return |
|
|
|
case <-notifier.Closed(): |
|
|
|
case <-notifier.Closed(): |
|
|
|
headersSub.Unsubscribe() |
|
|
|
|
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -267,6 +266,7 @@ func (api *FilterAPI) Logs(ctx context.Context, crit FilterCriteria) (*rpc.Subsc |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
defer logsSub.Unsubscribe() |
|
|
|
|
|
|
|
|
|
|
|
go func() { |
|
|
|
go func() { |
|
|
|
for { |
|
|
|
for { |
|
|
@ -277,10 +277,8 @@ func (api *FilterAPI) Logs(ctx context.Context, crit FilterCriteria) (*rpc.Subsc |
|
|
|
notifier.Notify(rpcSub.ID, &log) |
|
|
|
notifier.Notify(rpcSub.ID, &log) |
|
|
|
} |
|
|
|
} |
|
|
|
case <-rpcSub.Err(): // client send an unsubscribe request
|
|
|
|
case <-rpcSub.Err(): // client send an unsubscribe request
|
|
|
|
logsSub.Unsubscribe() |
|
|
|
|
|
|
|
return |
|
|
|
return |
|
|
|
case <-notifier.Closed(): // connection dropped
|
|
|
|
case <-notifier.Closed(): // connection dropped
|
|
|
|
logsSub.Unsubscribe() |
|
|
|
|
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|