reth
reth copied to clipboard
refactor: move receipts and block retrieval logic into cache
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 aBlockNumHashandbest_numberas parameters to determine whether to fetch both receipts and the block or just the receipts. - Removes redundant logic from
filter.rsby 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