mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-23 13:16:42 +00:00
eth/filters: notify with error check
Signed-off-by: jsvisa <delweng@gmail.com>
This commit is contained in:
parent
d30d0f0a15
commit
1380a479d2
1 changed files with 11 additions and 1 deletions
|
|
@ -345,6 +345,9 @@ func (api *FilterAPI) Logs(ctx context.Context, crit FilterCriteria) (*rpc.Subsc
|
||||||
case <-notifier.Closed():
|
case <-notifier.Closed():
|
||||||
rmLogsSub.Unsubscribe()
|
rmLogsSub.Unsubscribe()
|
||||||
return 0, errors.New("connection dropped")
|
return 0, errors.New("connection dropped")
|
||||||
|
case err := <-rpcSub.Err(): // client send an unsubscribe request
|
||||||
|
rmLogsSub.Unsubscribe()
|
||||||
|
return 0, err
|
||||||
case log := <-logChan:
|
case log := <-logChan:
|
||||||
notifier.Notify(rpcSub.ID, &log)
|
notifier.Notify(rpcSub.ID, &log)
|
||||||
case logs := <-rmLogsCh:
|
case logs := <-rmLogsCh:
|
||||||
|
|
@ -365,7 +368,14 @@ func (api *FilterAPI) Logs(ctx context.Context, crit FilterCriteria) (*rpc.Subsc
|
||||||
|
|
||||||
// send the reorged logs
|
// send the reorged logs
|
||||||
for _, log := range rmLogs {
|
for _, log := range rmLogs {
|
||||||
notifier.Notify(rpcSub.ID, &log)
|
select {
|
||||||
|
case <-notifier.Closed():
|
||||||
|
return head, errors.New("connection dropped")
|
||||||
|
case err := <-rpcSub.Err(): // client send an unsubscribe request
|
||||||
|
return head, err
|
||||||
|
default:
|
||||||
|
notifier.Notify(rpcSub.ID, &log)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// move forward to the next batch
|
// move forward to the next batch
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue