diff options
author | Florian Dold <florian.dold@gmail.com> | 2020-03-12 00:44:28 +0530 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2020-03-12 00:44:28 +0530 |
commit | 2c52046f0bf358a5e07c53394b3b72d091356cce (patch) | |
tree | 8993c992b9c8240ee865671cdfbab380e61af96c /src/operations/pending.ts | |
parent | 6e2881fabf74a3c1da8e94dcbe3e68fce6080d9e (diff) | |
download | wallet-core-2c52046f0bf358a5e07c53394b3b72d091356cce.tar.xz |
full recoup, untested/unfinished first attempt
Diffstat (limited to 'src/operations/pending.ts')
-rw-r--r-- | src/operations/pending.ts | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/operations/pending.ts b/src/operations/pending.ts index fce9a3bfb..08ec3fc9e 100644 --- a/src/operations/pending.ts +++ b/src/operations/pending.ts @@ -405,6 +405,32 @@ async function gatherPurchasePending( }); } +async function gatherRecoupPending( + tx: TransactionHandle, + now: Timestamp, + resp: PendingOperationsResponse, + onlyDue: boolean = false, +): Promise<void> { + await tx.iter(Stores.recoupGroups).forEach(rg => { + if (rg.timestampFinished) { + return; + } + resp.nextRetryDelay = updateRetryDelay( + resp.nextRetryDelay, + now, + rg.retryInfo.nextRetry, + ); + if (onlyDue && rg.retryInfo.nextRetry.t_ms > now.t_ms) { + return; + } + resp.pendingOperations.push({ + type: PendingOperationType.Recoup, + givesLifeness: true, + recoupGroupId: rg.recoupGroupId, + }); + }); +} + export async function getPendingOperations( ws: InternalWalletState, { onlyDue = false } = {}, @@ -420,6 +446,7 @@ export async function getPendingOperations( Stores.proposals, Stores.tips, Stores.purchases, + Stores.recoupGroups, ], async tx => { const walletBalance = await getBalancesInsideTransaction(ws, tx); @@ -436,6 +463,7 @@ export async function getPendingOperations( await gatherProposalPending(tx, now, resp, onlyDue); await gatherTipPending(tx, now, resp, onlyDue); await gatherPurchasePending(tx, now, resp, onlyDue); + await gatherRecoupPending(tx, now, resp, onlyDue); return resp; }, ); |