From b8b86ce2890fb048367d25882ba60c46c9606fab Mon Sep 17 00:00:00 2001 From: blindchaser Date: Tue, 21 Jan 2025 14:54:26 -0500 Subject: [PATCH] set FromBlock to latest --- evmrpc/subscribe.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/evmrpc/subscribe.go b/evmrpc/subscribe.go index 997a9ecd7..43b91a874 100644 --- a/evmrpc/subscribe.go +++ b/evmrpc/subscribe.go @@ -147,14 +147,14 @@ func (a *SubscriptionAPI) Logs(ctx context.Context, filter *filters.FilterCriter if filter == nil { filter = &filters.FilterCriteria{} } - // when fromBlock is 0 and toBlock is latest, adjust the filter // to unbounded filter if filter.FromBlock != nil && filter.FromBlock.Int64() == 0 && filter.ToBlock != nil && filter.ToBlock.Int64() < 0 { + latest := big.NewInt(a.logFetcher.ctxProvider(LatestCtxHeight).BlockHeight()) unboundedFilter := &filters.FilterCriteria{ - FromBlock: filter.FromBlock, // keep "0x0" to fetch historical logs - ToBlock: nil, // set to nil to continue listening + FromBlock: latest, // set to latest block height + ToBlock: nil, // set to nil to continue listening Addresses: filter.Addresses, Topics: filter.Topics, }