forked from comit-network/xmr-btc-swap
-
Notifications
You must be signed in to change notification settings - Fork 47
Refactor states #929
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.
Description
Current approach:
- Only the first few states contain all the details negotiated during swap setup
- The later states often don't contain that
- Always only access the state we're currently in for purity reasons
This frequently leads to situations where we can't (easily) do something in a later state because we can't (easily) access the information even though it is stored.
A workaround is to add the fields to the later states and then add a a migration which manually copies the field from the first states to keep backwards compatibility. This sucks and is highly error prone.
Example: #924 is caused by this.
Alternative approach:
- Distinguish between
struct SwapDetails(everything agreed upon during swap setup like swap id, keys of the parties, tx fees, addresses, etc) andenum Statewhich then only contains the information actually existing during that state. - Ability to always access
SwapDetailsfrom every state - Possibly distinguish between different paths (happy path / refund path / punish path) in the
Stateenum to hoist common fields
This would also fix #378 as the helper functions mostly use stuff from the SwapDetails.
Reactions are currently unavailable
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.