keep-network / keep-core

The smart contracts and reference client behind the Keep network
https://keep.network
MIT License
119 stars 74 forks source link

Optimize handling of non-existing transactions in the Electrum client #3809

Closed lukasz-zimnoch closed 5 months ago

lukasz-zimnoch commented 5 months ago

Electrum client exposes two methods for getting entire transactions and transaction confirmations from the Bitcoin blockchain. Those methods retry Electrum requests in case of any error. Retries are done in the exponential backoff scheme until a timeout of 2 minutes is hit.

However, when the given transaction does not exist on the chain, there is no point to retry. This can be harmful for scenarios like deposit sweep generation that need to check multiple transactions in a limited time window. If there are multiple non-existing transactions that are checked during the process, 2 minutes per such transaction is wasted.

Here we improve the situation by introducing an error type check. If the error says about not found transaction, retries are not executed.