From 1380a479d25513664f4637a6cb222b1eb5efadf4 Mon Sep 17 00:00:00 2001 From: jsvisa Date: Thu, 8 Jun 2023 08:55:30 +0000 Subject: [PATCH] eth/filters: notify with error check Signed-off-by: jsvisa --- eth/filters/api.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/eth/filters/api.go b/eth/filters/api.go index 4e3782f54d..6a48a9413c 100644 --- a/eth/filters/api.go +++ b/eth/filters/api.go @@ -345,6 +345,9 @@ func (api *FilterAPI) Logs(ctx context.Context, crit FilterCriteria) (*rpc.Subsc case <-notifier.Closed(): rmLogsSub.Unsubscribe() return 0, errors.New("connection dropped") + case err := <-rpcSub.Err(): // client send an unsubscribe request + rmLogsSub.Unsubscribe() + return 0, err case log := <-logChan: notifier.Notify(rpcSub.ID, &log) case logs := <-rmLogsCh: @@ -365,7 +368,14 @@ func (api *FilterAPI) Logs(ctx context.Context, crit FilterCriteria) (*rpc.Subsc // send the reorged logs 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