mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-23 13:16:42 +00:00
eth/filters: use a sole context
Signed-off-by: jsvisa <delweng@gmail.com>
This commit is contained in:
parent
dc6a5b1b3d
commit
870bf640aa
1 changed files with 4 additions and 1 deletions
|
|
@ -275,6 +275,9 @@ func (api *FilterAPI) Logs(ctx context.Context, crit FilterCriteria) (*rpc.Subsc
|
||||||
)
|
)
|
||||||
|
|
||||||
syncHistLogs := func(n int64) error {
|
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 {
|
for {
|
||||||
// get the latest block header
|
// get the latest block header
|
||||||
head := api.sys.backend.CurrentHeader().Number.Int64()
|
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
|
// do historical sync from n to head
|
||||||
f := api.sys.NewRangeFilter(n, head, crit.Addresses, crit.Topics)
|
f := api.sys.NewRangeFilter(n, head, crit.Addresses, crit.Topics)
|
||||||
logChan, errChan := f.rangeLogsAsync(ctx)
|
logChan, errChan := f.rangeLogsAsync(cctx)
|
||||||
|
|
||||||
// subscribe rmLogs
|
// subscribe rmLogs
|
||||||
query := ethereum.FilterQuery{FromBlock: big.NewInt(n), ToBlock: big.NewInt(head), Addresses: crit.Addresses, Topics: crit.Topics}
|
query := ethereum.FilterQuery{FromBlock: big.NewInt(n), ToBlock: big.NewInt(head), Addresses: crit.Addresses, Topics: crit.Topics}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue