diff options
author | aaronbuchwald <[email protected]> | 2020-10-26 22:03:05 -0400 |
---|---|---|
committer | GitHub <[email protected]> | 2020-10-26 22:03:05 -0400 |
commit | 806d04e9aa4b6e22fc2a484ada6fecb0c9a348e3 (patch) | |
tree | 36822cea4b16638e6a246af209ccdf77b3eb2088 /eth/filters | |
parent | 8a8ef56dd1a0f2cd28c6d4b3a579b16cdda6e2cf (diff) | |
parent | cccb47666b2bccce378a9a56824061ea3a9a95fa (diff) |
Merge pull request #43 from ava-labs/handle-block-number-requests
Handle block number requests
Diffstat (limited to 'eth/filters')
-rw-r--r-- | eth/filters/api.go | 5 | ||||
-rw-r--r-- | eth/filters/filter.go | 2 |
2 files changed, 7 insertions, 0 deletions
diff --git a/eth/filters/api.go b/eth/filters/api.go index 71e6454..9ee96af 100644 --- a/eth/filters/api.go +++ b/eth/filters/api.go @@ -330,6 +330,8 @@ func (api *PublicFilterAPI) GetLogs(ctx context.Context, crit FilterCriteria) ([ filter = NewBlockFilter(api.backend, *crit.BlockHash, crit.Addresses, crit.Topics) } else { // Convert the RPC block numbers into internal representations + // LatestBlockNumber is left in place here to be handled + // correctly within NewRangeFilter begin := rpc.LatestBlockNumber.Int64() if crit.FromBlock != nil { begin = crit.FromBlock.Int64() @@ -385,6 +387,9 @@ func (api *PublicFilterAPI) GetFilterLogs(ctx context.Context, id rpc.ID) ([]*ty filter = NewBlockFilter(api.backend, *f.crit.BlockHash, f.crit.Addresses, f.crit.Topics) } else { // Convert the RPC block numbers into internal representations + // Leave LatestBlockNumber in place here as the defaults + // Should be handled correctly as request for the last + // accepted block instead throughout all APIs. begin := rpc.LatestBlockNumber.Int64() if f.crit.FromBlock != nil { begin = f.crit.FromBlock.Int64() diff --git a/eth/filters/filter.go b/eth/filters/filter.go index 48a76c7..3c18e6e 100644 --- a/eth/filters/filter.go +++ b/eth/filters/filter.go @@ -129,6 +129,8 @@ func (f *Filter) Logs(ctx context.Context) ([]*types.Log, error) { return f.blockLogs(ctx, header) } // Figure out the limits of the filter range + // LatestBlockNumber is handled appropriately in HeaderByNumber + // so it is left in place here. header, _ := f.backend.HeaderByNumber(ctx, rpc.LatestBlockNumber) if header == nil { return nil, nil |