ape icon indicating copy to clipboard operation
ape copied to clipboard

Add `start_block` and `stop_block` to AccountHistory query

Open antazoey opened this issue 2 years ago • 3 comments

Overview

Currently, chain.account_history is in efficient because it check the entire account history every time you do a lookup. If we add the start_block and stop_block to get_account_transactions(), we can avoid checking unnecessary transactions and possibly avoiding HTTP calls.

Specification

    def get_account_transactions(self, address: AddressType, start_block: int = 0, stop_block: Optional[int] = None) -> Iterator["ReceiptAPI"]:

and then have AccountHistory track the block number and only request in the new block range on each subsequent call

Dependencies

Include links to any open issues that must be resolved before this feature can be implemented.

antazoey avatar Aug 11 '22 00:08 antazoey

A side issue to this: The receipts map is updated from the explorer in __getitem__ but not in __iter__ or items(), which is strange, it should probably keep in sync in all of them... but to loop through the explorer history that many times is not good either.

antazoey avatar Aug 11 '22 14:08 antazoey