[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-wallet-core] branch master updated: make retryInfo optional
From: |
gnunet |
Subject: |
[taler-wallet-core] branch master updated: make retryInfo optional |
Date: |
Fri, 11 Jun 2021 13:18:39 +0200 |
This is an automated email from the git hooks/post-receive script.
dold pushed a commit to branch master
in repository wallet-core.
The following commit(s) were added to refs/heads/master by this push:
new 7d15ce3d make retryInfo optional
7d15ce3d is described below
commit 7d15ce3d888ca93b2b33d994fed3e4cabb957f4d
Author: Florian Dold <florian@dold.me>
AuthorDate: Fri Jun 11 13:18:33 2021 +0200
make retryInfo optional
---
.../src/integrationtests/test-payment-fault.ts | 3 +++
packages/taler-wallet-core/src/db.ts | 2 +-
packages/taler-wallet-core/src/operations/pay.ts | 14 ++++++++++----
packages/taler-wallet-core/src/operations/pending.ts | 3 ++-
packages/taler-wallet-core/src/pending-types.ts | 2 +-
5 files changed, 17 insertions(+), 7 deletions(-)
diff --git
a/packages/taler-wallet-cli/src/integrationtests/test-payment-fault.ts
b/packages/taler-wallet-cli/src/integrationtests/test-payment-fault.ts
index 18ae72a6..71539a5f 100644
--- a/packages/taler-wallet-cli/src/integrationtests/test-payment-fault.ts
+++ b/packages/taler-wallet-cli/src/integrationtests/test-payment-fault.ts
@@ -185,8 +185,11 @@ export async function runPaymentFaultTest(t:
GlobalTestState) {
return;
}
if (faultCount < 3) {
+ console.log(`blocking /deposit request #${faultCount}`);
faultCount++;
ctx.dropResponse = true;
+ } else {
+ console.log(`letting through /deposit request #${faultCount}`);
}
},
});
diff --git a/packages/taler-wallet-core/src/db.ts
b/packages/taler-wallet-core/src/db.ts
index fb242e37..727e9de0 100644
--- a/packages/taler-wallet-core/src/db.ts
+++ b/packages/taler-wallet-core/src/db.ts
@@ -1332,7 +1332,7 @@ export interface PurchaseRecord {
abortStatus: AbortStatus;
- payRetryInfo: RetryInfo;
+ payRetryInfo?: RetryInfo;
lastPayError: TalerErrorDetails | undefined;
diff --git a/packages/taler-wallet-core/src/operations/pay.ts
b/packages/taler-wallet-core/src/operations/pay.ts
index 39adad70..9bfad177 100644
--- a/packages/taler-wallet-core/src/operations/pay.ts
+++ b/packages/taler-wallet-core/src/operations/pay.ts
@@ -51,6 +51,7 @@ import {
PreparePayResultType,
parsePayUri,
Logger,
+ getDurationRemaining,
} from "@gnu-taler/taler-util";
import { encodeCrock, getRandomBytes } from "../crypto/talerCrypto";
import {
@@ -522,10 +523,15 @@ async function incrementPurchasePayRetry(
return;
}
if (!pr.payRetryInfo) {
- return;
+ pr.payRetryInfo = initRetryInfo();
}
pr.payRetryInfo.retryCounter++;
updateRetryInfoTimeout(pr.payRetryInfo);
+ logger.trace(
+ `retrying pay in ${
+ getDurationRemaining(pr.payRetryInfo.nextRetry).d_ms
+ } ms`,
+ );
pr.lastPayError = err;
await tx.purchases.put(pr);
});
@@ -556,7 +562,7 @@ async function resetDownloadProposalRetry(
.runReadWrite(async (tx) => {
const p = await tx.proposals.get(proposalId);
if (p) {
- p.retryInfo = initRetryInfo();
+ delete p.retryInfo;
await tx.proposals.put(p);
}
});
@@ -1135,7 +1141,7 @@ async function submitPay(
// Hide transient errors.
if (
- purchase.payRetryInfo.retryCounter <= 5 &&
+ (purchase.payRetryInfo?.retryCounter ?? 0) <= 5 &&
resp.status >= 500 &&
resp.status <= 599
) {
@@ -1214,7 +1220,7 @@ async function submitPay(
);
// Hide transient errors.
if (
- purchase.payRetryInfo.retryCounter <= 5 &&
+ (purchase.payRetryInfo?.retryCounter ?? 0) <= 5 &&
resp.status >= 500 &&
resp.status <= 599
) {
diff --git a/packages/taler-wallet-core/src/operations/pending.ts
b/packages/taler-wallet-core/src/operations/pending.ts
index f0c9c9d8..8ab114ca 100644
--- a/packages/taler-wallet-core/src/operations/pending.ts
+++ b/packages/taler-wallet-core/src/operations/pending.ts
@@ -200,10 +200,11 @@ async function gatherPurchasePending(
): Promise<void> {
await tx.purchases.iter().forEach((pr) => {
if (pr.paymentSubmitPending && pr.abortStatus === AbortStatus.None) {
+ const timestampDue = pr.payRetryInfo?.nextRetry ?? getTimestampNow();
resp.pendingOperations.push({
type: PendingOperationType.Pay,
givesLifeness: true,
- timestampDue: pr.payRetryInfo.nextRetry,
+ timestampDue,
isReplay: false,
proposalId: pr.proposalId,
retryInfo: pr.payRetryInfo,
diff --git a/packages/taler-wallet-core/src/pending-types.ts
b/packages/taler-wallet-core/src/pending-types.ts
index 8198d439..02b4ec76 100644
--- a/packages/taler-wallet-core/src/pending-types.ts
+++ b/packages/taler-wallet-core/src/pending-types.ts
@@ -164,7 +164,7 @@ export interface PendingPayOperation {
type: PendingOperationType.Pay;
proposalId: string;
isReplay: boolean;
- retryInfo: RetryInfo;
+ retryInfo?: RetryInfo;
lastError: TalerErrorDetails | undefined;
}
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-wallet-core] branch master updated: make retryInfo optional,
gnunet <=