diff options
author | Florian Dold <florian.dold@gmail.com> | 2020-03-16 17:18:46 +0530 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2020-03-16 17:18:46 +0530 |
commit | 9e2be07cfc2267f817c22105ad2a147bc7f8c33e (patch) | |
tree | cba573c84f102dbe62a1ddfd250404b485202c65 /src/operations | |
parent | 1744b1a80063397105081a4d5aeec76936781345 (diff) |
fix bug in withdrawal operation state machine, allow manual reserve update from CLI
Diffstat (limited to 'src/operations')
-rw-r--r-- | src/operations/reserves.ts | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/operations/reserves.ts b/src/operations/reserves.ts index efca08a45..d19d069af 100644 --- a/src/operations/reserves.ts +++ b/src/operations/reserves.ts @@ -228,7 +228,7 @@ export async function forceQueryReserve( await tx.put(Stores.reserves, reserve); }); - await processReserve(ws, reservePub); + await processReserve(ws, reservePub, true); } /** @@ -490,6 +490,7 @@ async function updateReserve( reserveUpdateId, }; await tx.put(Stores.reserveUpdatedEvents, reserveUpdate); + r.reserveStatus = ReserveRecordStatus.WITHDRAWING; } else { const expectedBalance = Amounts.sub( r.amountWithdrawAllocated, @@ -497,7 +498,8 @@ async function updateReserve( ); const cmp = Amounts.cmp(balance, expectedBalance.amount); if (cmp == 0) { - // Nothing changed. + // Nothing changed, go back to sleep! + r.reserveStatus = ReserveRecordStatus.DORMANT; return; } if (cmp > 0) { @@ -506,8 +508,10 @@ async function updateReserve( r.amountWithdrawRemaining, extra, ).amount; + r.reserveStatus = ReserveRecordStatus.WITHDRAWING; } else { // We're missing some money. + r.reserveStatus = ReserveRecordStatus.DORMANT; } const reserveUpdate: ReserveUpdatedEventRecord = { reservePub: r.reservePub, @@ -520,12 +524,12 @@ async function updateReserve( await tx.put(Stores.reserveUpdatedEvents, reserveUpdate); } r.lastSuccessfulStatusQuery = getTimestampNow(); - r.reserveStatus = ReserveRecordStatus.WITHDRAWING; r.retryInfo = initRetryInfo(); r.reserveTransactions = reserveInfo.history; await tx.put(Stores.reserves, r); }, ); + console.log("updated reserve"); ws.notify({ type: NotificationType.ReserveUpdated }); } |