Skip to content

Refactor states #929

@Einliterflasche

Description

@Einliterflasche

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) and enum State which then only contains the information actually existing during that state.
  • Ability to always access SwapDetails from every state
  • Possibly distinguish between different paths (happy path / refund path / punish path) in the State enum to hoist common fields

This would also fix #378 as the helper functions mostly use stuff from the SwapDetails.

Metadata

Metadata

Assignees

No one assigned

    Labels

    AliceRelated to the maker state machineBobRelated to the taker state machinerefactoringRelated to refactorings. No new features are added.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions