Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
client/core: self-governed trades when server is down
When the client has active swaps on a server that is either down or mysteriously looses the market on which the trades was started, it is still necessary to complete these orders if a swap has been broadcast. In particular, the refund and auto-redeem/find-redemption paths need to work as expected. This change allows such trades to be loaded on startup even when the asset configurations are unavailable from the server for any reason. The lack of a market configuration or a DEX connection are also conditions for special handling. Trades in this state are flagged as "self-governed". In addition to flagging self-governed trades on startup and login (resumeTrades), the DEX connect and reconnect handlers now toggle the flag. The reconnect handler only removes the self-governed flag if the fresh market config includes the trade's market. To support safely redeeming a counter-party swap and other actions that depend on the asset configs (e.g. SwapConf, MaxFeeRate, etc)., this supplements the db.OrderMetaData struct with both to/from SwapConf values as they were when the order was placed. This also adds EpochDur to the struct to help with existing logic for handling stale cancels and other epoch orders, as well as epoch index computations when considered with the order's ServerTime stamp. While it is generally ill-advised to perform a client upgrade with active orders, this also tries during order loading to get these values if they were not stored (load as zero).
- Loading branch information