reth icon indicating copy to clipboard operation
reth copied to clipboard

refactor: move receipts and block retrieval logic into cache

Open reymom opened this issue 1 year ago • 0 comments
trafficstars

Description

This PR refactors the logic for fetching receipts and block data in filter.rs. The logic for checking whether a block is near the tip (last 4 blocks) has been moved into the cache, simplifying the filter.rs code. This refactor:

  • Introduces a new function in EthStateCache: get_receipts_and_maybe_block, which takes a BlockNumHash and best_number as parameters to determine whether to fetch both receipts and the block or just the receipts.
  • Removes redundant logic from filter.rs by directly calling the cache function.
  • The function now handles the logic for whether the block is near the tip or not, making the cache responsible for deciding the data to return.

Testing

All existing tests pass. This change does not introduce any new functionality, but centralizes and simplifies existing logic.

Closes #11610

reymom avatar Oct 12 '24 16:10 reymom