From 390a4b301828cbcfbc3e1ef6641d5b7a193490c5 Mon Sep 17 00:00:00 2001 From: jsvisa Date: Thu, 8 Jun 2023 08:20:24 +0000 Subject: [PATCH] eth/filters: more accurate check of live or hist Signed-off-by: jsvisa --- eth/filters/api.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/eth/filters/api.go b/eth/filters/api.go index ebb2a45a2f..fa78629c95 100644 --- a/eth/filters/api.go +++ b/eth/filters/api.go @@ -299,8 +299,12 @@ func (api *FilterAPI) Logs(ctx context.Context, crit FilterCriteria) (*rpc.Subsc return nil } + isLiveFilter := true + if crit.FromBlock != nil { + isLiveFilter = crit.FromBlock.Sign() < 0 + } // do live filter only - if crit.FromBlock == nil { + if isLiveFilter { err := filterLiveLogs() return rpcSub, err } @@ -346,11 +350,11 @@ func (api *FilterAPI) Logs(ctx context.Context, crit FilterCriteria) (*rpc.Subsc } } case err := <-errChan: + // range filter is done or error, let's also stop the rmLogs subscribe + rmLogsSub.Unsubscribe() if err != nil { return err } - // range filter is done, let's also stop the rmLogs subscribe - rmLogsSub.Unsubscribe() break FORLOOP } }