forked from comit-network/xmr-btc-swap
-
Notifications
You must be signed in to change notification settings - Fork 46
Better retry system #898
Copy link
Copy link
Open
Labels
AliceRelated to the maker state machineRelated to the maker state machineBobRelated to the taker state machineRelated to the taker state machinerefactoringRelated to refactorings. No new features are added.Related to refactorings. No new features are added.
Metadata
Metadata
Assignees
Labels
AliceRelated to the maker state machineRelated to the maker state machineBobRelated to the taker state machineRelated to the taker state machinerefactoringRelated to refactorings. No new features are added.Related to refactorings. No new features are added.
At least in the swap state machine we have retries sprinkled all over the place. They require a lot of boilerplate.
We should find a way to hoist the retries into
fn run_until. It should be possible to use a thin warapper around anyhow::Error which can be easily converted back and forth but carries retry information. Maybe only persistent vs transient error. Maybe we can extend it to include retry configs (timeout, backoff, ...). Error returned byfn next_statewould be (by default) treated as transient with sensible defaults, with the option to easily override this using syntax something like this:Currently the small retry blocks used in many places of the state machinery add a LOT of boilerplate. Not just moving the code into a closure and specifying (mostly the same) retry config and mapping errors (
.map_err(backoff::Error::transient)). We also have to clone a handful of variables each time (bitcoin wallet, state, ...). This makes the whole state machine much more verbose than it'd need to be and harder to parse / spot issues.