gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-wallet-core] 01/02: pending fixes


From: gnunet
Subject: [taler-wallet-core] 01/02: pending fixes
Date: Fri, 06 Dec 2019 11:01:47 +0100

This is an automated email from the git hooks/post-receive script.

dold pushed a commit to branch master
in repository wallet-core.

commit e01f94e345bd94afe1643b55434a00c106d18954
Author: Florian Dold <address@hidden>
AuthorDate: Fri Dec 6 03:23:35 2019 +0100

    pending fixes
---
 src/wallet-impl/pending.ts  | 49 +++++++++++++++++++++++++++++++--------------
 src/wallet-impl/reserves.ts |  6 ++++++
 src/walletTypes.ts          | 14 ++++++++++++-
 3 files changed, 53 insertions(+), 16 deletions(-)

diff --git a/src/wallet-impl/pending.ts b/src/wallet-impl/pending.ts
index b0ae71f6..2d4b16cf 100644
--- a/src/wallet-impl/pending.ts
+++ b/src/wallet-impl/pending.ts
@@ -139,25 +139,17 @@ async function gatherReservePending(
     if (!reserve.retryInfo.active) {
       return;
     }
-    resp.nextRetryDelay = updateRetryDelay(
-      resp.nextRetryDelay,
-      now,
-      reserve.retryInfo.nextRetry,
-    );
-    if (onlyDue && reserve.retryInfo.nextRetry.t_ms > now.t_ms) {
-      return;
-    }
     switch (reserve.reserveStatus) {
       case ReserveRecordStatus.DORMANT:
         // nothing to report as pending
         break;
-      case ReserveRecordStatus.WITHDRAWING:
       case ReserveRecordStatus.UNCONFIRMED:
-      case ReserveRecordStatus.QUERYING_STATUS:
-      case ReserveRecordStatus.REGISTERING_BANK:
+        if (onlyDue) {
+          break;
+        }
         resp.pendingOperations.push({
           type: "reserve",
-          givesLifeness: true,
+          givesLifeness: false,
           stage: reserve.reserveStatus,
           timestampCreated: reserve.created,
           reserveType,
@@ -166,9 +158,12 @@ async function gatherReservePending(
         });
         break;
       case ReserveRecordStatus.WAIT_CONFIRM_BANK:
+        if (onlyDue) {
+          break;
+        }
         resp.pendingOperations.push({
           type: "reserve",
-          givesLifeness: true,
+          givesLifeness: false,
           stage: reserve.reserveStatus,
           timestampCreated: reserve.created,
           reserveType,
@@ -177,6 +172,27 @@ async function gatherReservePending(
           retryInfo: reserve.retryInfo,
         });
         break;
+      case ReserveRecordStatus.WITHDRAWING:
+      case ReserveRecordStatus.QUERYING_STATUS:
+      case ReserveRecordStatus.REGISTERING_BANK:
+        resp.nextRetryDelay = updateRetryDelay(
+          resp.nextRetryDelay,
+          now,
+          reserve.retryInfo.nextRetry,
+        );
+        if (onlyDue && reserve.retryInfo.nextRetry.t_ms > now.t_ms) {
+          return;
+        }
+        resp.pendingOperations.push({
+          type: "reserve",
+          givesLifeness: true,
+          stage: reserve.reserveStatus,
+          timestampCreated: reserve.created,
+          reserveType,
+          reservePub: reserve.reservePub,
+          retryInfo: reserve.retryInfo,
+        });
+        break;
       default:
         resp.pendingOperations.push({
           type: "bug",
@@ -265,7 +281,10 @@ async function gatherWithdrawalPending(
     if (onlyDue && wsr.retryInfo.nextRetry.t_ms > now.t_ms) {
       return;
     }
-    const numCoinsWithdrawn = wsr.withdrawn.reduce((a, x) => a + (x ? 1 : 0), 
0);
+    const numCoinsWithdrawn = wsr.withdrawn.reduce(
+      (a, x) => a + (x ? 1 : 0),
+      0,
+    );
     const numCoinsTotal = wsr.withdrawn.length;
     resp.pendingOperations.push({
       type: "withdraw",
@@ -352,7 +371,7 @@ async function gatherPurchasePending(
   resp: PendingOperationsResponse,
   onlyDue: boolean = false,
 ): Promise<void> {
-  await tx.iter(Stores.purchases).forEach((pr) => {
+  await tx.iter(Stores.purchases).forEach(pr => {
     if (!pr.firstSuccessfulPayTimestamp) {
       resp.nextRetryDelay = updateRetryDelay(
         resp.nextRetryDelay,
diff --git a/src/wallet-impl/reserves.ts b/src/wallet-impl/reserves.ts
index 8a700beb..8b8fbc7e 100644
--- a/src/wallet-impl/reserves.ts
+++ b/src/wallet-impl/reserves.ts
@@ -174,6 +174,8 @@ export async function createReserve(
     },
   );
 
+  ws.notify({ type: NotificationType.ReserveCreated });
+
   // Asynchronously process the reserve, but return
   // to the caller already.
   processReserve(ws, resp.reservePub, true).catch(e => {
@@ -244,6 +246,7 @@ async function registerReserveWithBank(
     r.retryInfo = initRetryInfo();
     return r;
   });
+  ws.notify( { type: NotificationType.Wildcard });
   return processReserveBankStatus(ws, reservePub);
 }
 
@@ -284,6 +287,8 @@ async function processReserveBankStatusImpl(
     throw e;
   }
 
+  ws.notify( { type: NotificationType.Wildcard });
+
   if (status.selection_done) {
     if (reserve.reserveStatus === ReserveRecordStatus.REGISTERING_BANK) {
       await registerReserveWithBank(ws, reservePub);
@@ -322,6 +327,7 @@ async function processReserveBankStatusImpl(
       return r;
     });
   }
+  ws.notify( { type: NotificationType.Wildcard });
 }
 
 async function incrementReserveRetry(
diff --git a/src/walletTypes.ts b/src/walletTypes.ts
index 6e246c68..4c345870 100644
--- a/src/walletTypes.ts
+++ b/src/walletTypes.ts
@@ -519,6 +519,7 @@ export const enum NotificationType {
   ReserveUpdated = "reserve-updated",
   ReserveConfirmed = "reserve-confirmed",
   ReserveDepleted = "reserve-depleted",
+  ReserveCreated = "reserve-created",
   WithdrawSessionCreated = "withdraw-session-created",
   WithdrawSessionFinished = "withdraw-session-finished",
   WaitingForRetry = "waiting-for-retry",
@@ -534,6 +535,7 @@ export const enum NotificationType {
   PayOperationError = "pay-error",
   WithdrawOperationError = "withdraw-error",
   ReserveOperationError = "reserve-error",
+  Wildcard = "wildcard",
 }
 
 export interface ProposalAcceptedNotification {
@@ -656,6 +658,14 @@ export interface ReserveOperationErrorNotification {
   type: NotificationType.ReserveOperationError;
 }
 
+export interface ReserveCreatedNotification {
+  type: NotificationType.ReserveCreated;
+}
+
+export interface WildcardNotification {
+  type: NotificationType.Wildcard;
+}
+
 export type WalletNotification =
   | WithdrawOperationErrorNotification
   | ReserveOperationErrorNotification
@@ -676,6 +686,7 @@ export type WalletNotification =
   | RefreshStartedNotification
   | RefreshRefusedNotification
   | ReserveUpdatedNotification
+  | ReserveCreatedNotification
   | ReserveConfirmedNotification
   | WithdrawSessionFinishedNotification
   | ReserveDepletedNotification
@@ -684,7 +695,8 @@ export type WalletNotification =
   | RefundFinishedNotification
   | RefundQueriedNotification
   | WithdrawSessionCreatedNotification
-  | CoinWithdrawnNotification;
+  | CoinWithdrawnNotification
+  | WildcardNotification;
 
 export interface OperationError {
   type: string;

-- 
To stop receiving notification emails like this one, please contact
address@hidden.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]