gnunet-svn
[Top][All Lists]
Advanced

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

[taler-wallet-core] branch master updated (4159367d -> 52da599d)


From: gnunet
Subject: [taler-wallet-core] branch master updated (4159367d -> 52da599d)
Date: Fri, 06 Dec 2019 11:01:46 +0100

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

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

    from 4159367d pending ops / history / notification tweaks
     new e01f94e3 pending fixes
     new 52da599d don't die on auto-refund, fix pending operations

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/talerTypes.ts           |  6 ++++++
 src/wallet-impl/pending.ts  | 40 +++++++++++++++++++---------------
 src/wallet-impl/reserves.ts |  7 ++++++
 src/wallet.ts               | 52 ++++++++++++++++++++++++++++++++-------------
 src/walletTypes.ts          | 22 +++++++++++++------
 5 files changed, 88 insertions(+), 39 deletions(-)

diff --git a/src/talerTypes.ts b/src/talerTypes.ts
index a6581367..91dd913b 100644
--- a/src/talerTypes.ts
+++ b/src/talerTypes.ts
@@ -310,6 +310,12 @@ export class ContractTerms {
   @Checkable.String()
   H_wire: string;
 
+  /**
+   * Hash of the merchant's wire details.
+   */
+  @Checkable.Optional(Checkable.String())
+  auto_refund: string;
+
   /**
    * Wire method the merchant wants to use.
    */
diff --git a/src/wallet-impl/pending.ts b/src/wallet-impl/pending.ts
index b0ae71f6..02f8d9ef 100644
--- a/src/wallet-impl/pending.ts
+++ b/src/wallet-impl/pending.ts
@@ -18,7 +18,6 @@
  * Imports.
  */
 import {
-  PendingOperationInfo,
   PendingOperationsResponse,
   getTimestampNow,
   Timestamp,
@@ -139,25 +138,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,6 +157,17 @@ async function gatherReservePending(
         });
         break;
       case ReserveRecordStatus.WAIT_CONFIRM_BANK:
+      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,
@@ -173,7 +175,6 @@ async function gatherReservePending(
           timestampCreated: reserve.created,
           reserveType,
           reservePub: reserve.reservePub,
-          bankWithdrawConfirmUrl: reserve.bankWithdrawConfirmUrl,
           retryInfo: reserve.retryInfo,
         });
         break;
@@ -265,7 +266,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",
@@ -308,9 +312,11 @@ async function gatherProposalPending(
       resp.pendingOperations.push({
         type: "proposal-download",
         givesLifeness: true,
-        merchantBaseUrl: proposal.download!!.contractTerms.merchant_base_url,
+        merchantBaseUrl: proposal.download?.contractTerms.merchant_base_url || 
"",
         proposalId: proposal.proposalId,
         proposalTimestamp: proposal.timestamp,
+        lastError: proposal.lastError,
+        retryInfo: proposal.retryInfo,
       });
     }
   });
@@ -352,7 +358,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..d6568bd3 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);
@@ -321,7 +326,9 @@ async function processReserveBankStatusImpl(
       r.bankWithdrawConfirmUrl = status.confirm_transfer_url;
       return r;
     });
+    await incrementReserveRetry(ws, reservePub, undefined);
   }
+  ws.notify( { type: NotificationType.Wildcard });
 }
 
 async function incrementReserveRetry(
diff --git a/src/wallet.ts b/src/wallet.ts
index 276e3c37..a4fc09f7 100644
--- a/src/wallet.ts
+++ b/src/wallet.ts
@@ -295,20 +295,17 @@ export class Wallet {
             numGivingLiveness++;
           }
         }
-        let timeout;
+        let dt;
         if (
           allPending.pendingOperations.length === 0 ||
           allPending.nextRetryDelay.d_ms === Number.MAX_SAFE_INTEGER
         ) {
-          // Wait forever
-          timeout = new Promise(() => {});
-          console.log("waiting forever");
+          // Wait for 5 seconds
+          dt = 5000;
         } else {
-          console.log("waiting for timeout", pending.nextRetryDelay);
-          timeout = this.timerGroup.resolveAfter(
-            allPending.nextRetryDelay.d_ms,
-          );
+          dt = Math.min(5000, allPending.nextRetryDelay.d_ms);
         }
+        const timeout = this.timerGroup.resolveAfter(dt);
         this.ws.notify({
           type: NotificationType.WaitingForRetry,
           numGivingLiveness,
@@ -319,7 +316,7 @@ export class Wallet {
       } else {
         logger.trace("running pending operations that are due");
         // FIXME: maybe be a bit smarter about executing these
-        // opeations in parallel?
+        // operations in parallel?
         for (const p of pending.pendingOperations) {
           try {
             console.log("running", p);
@@ -327,6 +324,7 @@ export class Wallet {
           } catch (e) {
             console.error(e);
           }
+          this.ws.notify({ type: NotificationType.Wildcard });
         }
       }
     }
@@ -481,7 +479,11 @@ export class Wallet {
     baseUrl: string,
     force: boolean = false,
   ): Promise<ExchangeRecord> {
-    return updateExchangeFromUrl(this.ws, baseUrl, force);
+    try {
+      return updateExchangeFromUrl(this.ws, baseUrl, force);
+    } finally {
+      this.latch.trigger();
+    }
   }
 
   /**
@@ -492,7 +494,11 @@ export class Wallet {
   }
 
   async refresh(oldCoinPub: string, force: boolean = false): Promise<void> {
-    return refresh(this.ws, oldCoinPub, force);
+    try {
+      return refresh(this.ws, oldCoinPub, force);
+    } catch (e) {
+      this.latch.trigger();
+    }
   }
 
   async findExchange(
@@ -638,7 +644,11 @@ export class Wallet {
   }
 
   async acceptTip(talerTipUri: string): Promise<void> {
-    return acceptTip(this.ws, talerTipUri);
+    try {
+      return acceptTip(this.ws, talerTipUri);
+    } catch (e) {
+      this.latch.trigger();
+    }
   }
 
   async getTipStatus(talerTipUri: string): Promise<TipStatus> {
@@ -646,7 +656,11 @@ export class Wallet {
   }
 
   async abortFailedPayment(contractTermsHash: string): Promise<void> {
-    return abortFailedPayment(this.ws, contractTermsHash);
+    try {
+      return abortFailedPayment(this.ws, contractTermsHash);
+    } finally {
+      this.latch.trigger();
+    }
   }
 
   public async handleNotifyReserve() {
@@ -680,14 +694,22 @@ export class Wallet {
   async getWithdrawalInfo(
     talerWithdrawUri: string,
   ): Promise<DownloadedWithdrawInfo> {
-    return getWithdrawalInfo(this.ws, talerWithdrawUri);
+    try {
+      return getWithdrawalInfo(this.ws, talerWithdrawUri);
+    } finally {
+      this.latch.trigger();
+    }
   }
 
   async acceptWithdrawal(
     talerWithdrawUri: string,
     selectedExchange: string,
   ): Promise<AcceptWithdrawalResponse> {
-    return acceptWithdrawal(this.ws, talerWithdrawUri, selectedExchange);
+    try {
+      return acceptWithdrawal(this.ws, talerWithdrawUri, selectedExchange);
+    } finally {
+      this.latch.trigger();
+    }
   }
 
   async getPurchaseDetails(hc: string): Promise<PurchaseDetails> {
diff --git a/src/walletTypes.ts b/src/walletTypes.ts
index 6e246c68..40787166 100644
--- a/src/walletTypes.ts
+++ b/src/walletTypes.ts
@@ -236,12 +236,6 @@ export interface HistoryEvent {
    */
   timestamp: Timestamp;
 
-  /**
-   * Subject of the entry.  Used to group multiple history records together.
-   * Only the latest history record with the same subjectId will be shown.
-   */
-  subjectId?: string;
-
   /**
    * Details used when rendering the history record.
    */
@@ -519,6 +513,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 +529,7 @@ export const enum NotificationType {
   PayOperationError = "pay-error",
   WithdrawOperationError = "withdraw-error",
   ReserveOperationError = "reserve-error",
+  Wildcard = "wildcard",
 }
 
 export interface ProposalAcceptedNotification {
@@ -656,6 +652,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 +680,7 @@ export type WalletNotification =
   | RefreshStartedNotification
   | RefreshRefusedNotification
   | ReserveUpdatedNotification
+  | ReserveCreatedNotification
   | ReserveConfirmedNotification
   | WithdrawSessionFinishedNotification
   | ReserveDepletedNotification
@@ -684,7 +689,8 @@ export type WalletNotification =
   | RefundFinishedNotification
   | RefundQueriedNotification
   | WithdrawSessionCreatedNotification
-  | CoinWithdrawnNotification;
+  | CoinWithdrawnNotification
+  | WildcardNotification;
 
 export interface OperationError {
   type: string;
@@ -735,6 +741,8 @@ export interface PendingProposalDownloadOperation {
   merchantBaseUrl: string;
   proposalTimestamp: Timestamp;
   proposalId: string;
+  lastError?: OperationError;
+  retryInfo: RetryInfo;
 }
 
 /**

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



reply via email to

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