diff options
author | Florian Dold <florian.dold@gmail.com> | 2020-09-02 14:44:36 +0530 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2020-09-02 14:44:40 +0530 |
commit | 8a3ac7f08b114360118bf58a38983401107a62cf (patch) | |
tree | ecace89f8b01818f1d521760d987ff02d5cdd33c /packages/taler-wallet-core/src/operations/pending.ts | |
parent | 8d0081b62248f0663e3b4e1ba5246b454f5823db (diff) | |
download | wallet-core-8a3ac7f08b114360118bf58a38983401107a62cf.tar.xz |
schedule exchange updating
Diffstat (limited to 'packages/taler-wallet-core/src/operations/pending.ts')
-rw-r--r-- | packages/taler-wallet-core/src/operations/pending.ts | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/packages/taler-wallet-core/src/operations/pending.ts b/packages/taler-wallet-core/src/operations/pending.ts index 881961627..8cbc5e569 100644 --- a/packages/taler-wallet-core/src/operations/pending.ts +++ b/packages/taler-wallet-core/src/operations/pending.ts @@ -56,10 +56,6 @@ async function gatherExchangePending( resp: PendingOperationsResponse, onlyDue = false, ): Promise<void> { - if (onlyDue) { - // FIXME: exchanges should also be updated regularly - return; - } await tx.iter(Stores.exchanges).forEach((e) => { switch (e.updateStatus) { case ExchangeUpdateStatus.Finished: @@ -79,7 +75,7 @@ async function gatherExchangePending( type: PendingOperationType.Bug, givesLifeness: false, message: - "Exchange record does not have details, but no update in progress.", + "Exchange record does not have details, but no update finished.", details: { exchangeBaseUrl: e.baseUrl, }, @@ -90,14 +86,28 @@ async function gatherExchangePending( type: PendingOperationType.Bug, givesLifeness: false, message: - "Exchange record does not have wire info, but no update in progress.", + "Exchange record does not have wire info, but no update finished.", details: { exchangeBaseUrl: e.baseUrl, }, }); } + if (e.details && e.details.nextUpdateTime.t_ms < now.t_ms) { + resp.pendingOperations.push({ + type: PendingOperationType.ExchangeUpdate, + givesLifeness: false, + stage: ExchangeUpdateOperationStage.FetchKeys, + exchangeBaseUrl: e.baseUrl, + lastError: e.lastError, + reason: "scheduled", + }); + break; + } break; case ExchangeUpdateStatus.FetchKeys: + if (onlyDue && e.retryInfo.nextRetry.t_ms > now.t_ms) { + return; + } resp.pendingOperations.push({ type: PendingOperationType.ExchangeUpdate, givesLifeness: false, @@ -108,6 +118,9 @@ async function gatherExchangePending( }); break; case ExchangeUpdateStatus.FetchWire: + if (onlyDue && e.retryInfo.nextRetry.t_ms > now.t_ms) { + return; + } resp.pendingOperations.push({ type: PendingOperationType.ExchangeUpdate, givesLifeness: false, @@ -118,6 +131,9 @@ async function gatherExchangePending( }); break; case ExchangeUpdateStatus.FinalizeUpdate: + if (onlyDue && e.retryInfo.nextRetry.t_ms > now.t_ms) { + return; + } resp.pendingOperations.push({ type: PendingOperationType.ExchangeUpdate, givesLifeness: false, |