From 870bf640aa6d575f99f93b4ad95787df78b14b1d Mon Sep 17 00:00:00 2001 From: jsvisa Date: Thu, 8 Jun 2023 07:19:48 +0000 Subject: [PATCH] eth/filters: use a sole context Signed-off-by: jsvisa --- eth/filters/api.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/eth/filters/api.go b/eth/filters/api.go index 9dd084fc93..0eb977cadf 100644 --- a/eth/filters/api.go +++ b/eth/filters/api.go @@ -275,6 +275,9 @@ func (api *FilterAPI) Logs(ctx context.Context, crit FilterCriteria) (*rpc.Subsc ) syncHistLogs := func(n int64) error { + // the ctx will be canceled after this function is called + // and we are run in a background goroutine, use a new context instead + cctx := context.Background() for { // get the latest block header head := api.sys.backend.CurrentHeader().Number.Int64() @@ -284,7 +287,7 @@ func (api *FilterAPI) Logs(ctx context.Context, crit FilterCriteria) (*rpc.Subsc // do historical sync from n to head f := api.sys.NewRangeFilter(n, head, crit.Addresses, crit.Topics) - logChan, errChan := f.rangeLogsAsync(ctx) + logChan, errChan := f.rangeLogsAsync(cctx) // subscribe rmLogs query := ethereum.FilterQuery{FromBlock: big.NewInt(n), ToBlock: big.NewInt(head), Addresses: crit.Addresses, Topics: crit.Topics}