eth/filters: notify with error check

Signed-off-by: jsvisa <delweng@gmail.com>
This commit is contained in:
jsvisa 2023-06-08 08:55:30 +00:00
parent d30d0f0a15
commit 1380a479d2

View file

@ -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,8 +368,15 @@ 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 {
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) notifier.Notify(rpcSub.ID, &log)
} }
}
// move forward to the next batch // move forward to the next batch
n = head + 1 n = head + 1