Skip to content

Commit

Permalink
set FromBlock to latest
Browse files Browse the repository at this point in the history
  • Loading branch information
blindchaser committed Jan 21, 2025
1 parent b544fba commit b8b86ce
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions evmrpc/subscribe.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down

0 comments on commit b8b86ce

Please sign in to comment.