nimiq / safe

MIT License
8 stars 8 forks source link

Throttle fetching account history to avoid getting blocked #151

Open danimoh opened 5 years ago

danimoh commented 5 years ago

When fetching the transaction history of addresses with a lot of transactions, connected clients refuse further requests at some point. To circumvent this and to be able to sync the entire transaction history, a throttling mechanism should be added.

sisou commented 4 years ago

Alternatively, or in addition to throttling, only the transaction history of the currently active account should be fetched. The new client API also supports limiting the number of tx fetched for each address, which can be used to only fetch the last 100 first (instead of the full 500 per address).

sisou commented 4 years ago

Mainly resolved by soft-failing the tx-history request in nano-api (https://github.com/nimiq/nano-api/commit/3c93c58559fd6b08e6a70b4fb83b4f79a690f901) and fetching only the history of the currently active addresses (https://github.com/nimiq/safe/commit/3b5f79f4f254103510a919a1947abcc170ca3a90).

The nano-api also now returns if the request was rate-limited in the result of the tx-history request, so the only thing missing in the Safe is showing a notice to the user when they were rate-limited, and to tell them to try again in a few minutes.