gnunet-svn
[Top][All Lists]
Advanced

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

[taler-wallet-core] branch master updated: DB tweaks


From: gnunet
Subject: [taler-wallet-core] branch master updated: DB tweaks
Date: Tue, 08 Sep 2020 17:33:20 +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 aae06c68 DB tweaks
aae06c68 is described below

commit aae06c680f7d31d0a2f2a2059b57a8d7c575d3c7
Author: Florian Dold <florian.dold@gmail.com>
AuthorDate: Tue Sep 8 21:03:10 2020 +0530

    DB tweaks
---
 .../taler-wallet-core/src/operations/exchanges.ts  |  8 +++---
 packages/taler-wallet-core/src/operations/pay.ts   |  8 +++---
 .../taler-wallet-core/src/operations/refresh.ts    |  8 +++---
 .../taler-wallet-core/src/operations/refund.ts     | 21 +++++++-------
 .../taler-wallet-core/src/operations/reserves.ts   |  8 ------
 packages/taler-wallet-core/src/operations/tip.ts   | 15 +++++-----
 .../taler-wallet-core/src/operations/withdraw.ts   |  8 +++---
 packages/taler-wallet-core/src/types/dbTypes.ts    | 27 +-----------------
 packages/taler-wallet-core/src/wallet.ts           | 32 +---------------------
 9 files changed, 37 insertions(+), 98 deletions(-)

diff --git a/packages/taler-wallet-core/src/operations/exchanges.ts 
b/packages/taler-wallet-core/src/operations/exchanges.ts
index 7bf07ab2..d598e398 100644
--- a/packages/taler-wallet-core/src/operations/exchanges.ts
+++ b/packages/taler-wallet-core/src/operations/exchanges.ts
@@ -222,7 +222,7 @@ async function updateExchangeWithKeys(
       for (const newDenom of newDenominations) {
         const oldDenom = await tx.get(Stores.denominations, [
           baseUrl,
-          newDenom.denomPub,
+          newDenom.denomPubHash,
         ]);
         if (oldDenom) {
           // FIXME: Do consistency check
@@ -236,10 +236,10 @@ async function updateExchangeWithKeys(
       const newlyRevokedCoinPubs: string[] = [];
       logger.trace("recoup list from exchange", recoupDenomList);
       for (const recoupInfo of recoupDenomList) {
-        const oldDenom = await tx.getIndexed(
-          Stores.denominations.denomPubHashIndex,
+        const oldDenom = await tx.get(Stores.denominations, [
+          r.baseUrl,
           recoupInfo.h_denom_pub,
-        );
+        ]);
         if (!oldDenom) {
           // We never even knew about the revoked denomination, all good.
           continue;
diff --git a/packages/taler-wallet-core/src/operations/pay.ts 
b/packages/taler-wallet-core/src/operations/pay.ts
index a6f941ff..3dc5e160 100644
--- a/packages/taler-wallet-core/src/operations/pay.ts
+++ b/packages/taler-wallet-core/src/operations/pay.ts
@@ -131,7 +131,7 @@ export async function getTotalPaymentCost(
     }
     const denom = await ws.db.get(Stores.denominations, [
       coin.exchangeBaseUrl,
-      coin.denomPub,
+      coin.denomPubHash,
     ]);
     if (!denom) {
       throw Error(
@@ -332,7 +332,7 @@ async function getCoinsForPayment(
     // coins have the same currency
     const firstDenom = await ws.db.get(Stores.denominations, [
       exchange.baseUrl,
-      coins[0].denomPub,
+      coins[0].denomPubHash,
     ]);
     if (!firstDenom) {
       throw Error("db inconsistent");
@@ -342,7 +342,7 @@ async function getCoinsForPayment(
     for (const coin of coins) {
       const denom = await ws.db.get(Stores.denominations, [
         exchange.baseUrl,
-        coin.denomPub,
+        coin.denomPubHash,
       ]);
       if (!denom) {
         throw Error("db inconsistent");
@@ -1148,7 +1148,7 @@ export async function confirmPay(
     }
     const denom = await ws.db.get(Stores.denominations, [
       coin.exchangeBaseUrl,
-      coin.denomPub,
+      coin.denomPubHash,
     ]);
     if (!denom) {
       throw Error(
diff --git a/packages/taler-wallet-core/src/operations/refresh.ts 
b/packages/taler-wallet-core/src/operations/refresh.ts
index a6917c28..c92ce920 100644
--- a/packages/taler-wallet-core/src/operations/refresh.ts
+++ b/packages/taler-wallet-core/src/operations/refresh.ts
@@ -134,7 +134,7 @@ async function refreshCreateSession(
 
   const oldDenom = await ws.db.get(Stores.denominations, [
     exchange.baseUrl,
-    coin.denomPub,
+    coin.denomPubHash,
   ]);
 
   if (!oldDenom) {
@@ -367,7 +367,7 @@ async function refreshReveal(
   for (let i = 0; i < reveal.ev_sigs.length; i++) {
     const denom = await ws.db.get(Stores.denominations, [
       refreshSession.exchangeBaseUrl,
-      refreshSession.newDenoms[i],
+      refreshSession.newDenomHashes[i],
     ]);
     if (!denom) {
       console.error("denom not found");
@@ -598,7 +598,7 @@ export async function createRefreshGroup(
     checkDbInvariant(!!coin, "coin must be in database");
     const denom = await tx.get(Stores.denominations, [
       coin.exchangeBaseUrl,
-      coin.denomPub,
+      coin.denomPubHash,
     ]);
     checkDbInvariant(
       !!denom,
@@ -701,7 +701,7 @@ export async function autoRefresh(
         }
         const denom = await tx.get(Stores.denominations, [
           exchangeBaseUrl,
-          coin.denomPub,
+          coin.denomPubHash,
         ]);
         if (!denom) {
           logger.warn("denomination not in database");
diff --git a/packages/taler-wallet-core/src/operations/refund.ts 
b/packages/taler-wallet-core/src/operations/refund.ts
index 097e2086..e15a27b3 100644
--- a/packages/taler-wallet-core/src/operations/refund.ts
+++ b/packages/taler-wallet-core/src/operations/refund.ts
@@ -104,10 +104,10 @@ async function applySuccessfulRefund(
     console.warn("coin not found, can't apply refund");
     return;
   }
-  const denom = await tx.getIndexed(
-    Stores.denominations.denomPubHashIndex,
+  const denom = await tx.get(Stores.denominations, [
+    coin.exchangeBaseUrl,
     coin.denomPubHash,
-  );
+  ]);
   if (!denom) {
     throw Error("inconsistent database");
   }
@@ -161,10 +161,10 @@ async function storePendingRefund(
     console.warn("coin not found, can't apply refund");
     return;
   }
-  const denom = await tx.getIndexed(
-    Stores.denominations.denomPubHashIndex,
+  const denom = await tx.get(Stores.denominations, [
+    coin.exchangeBaseUrl,
     coin.denomPubHash,
-  );
+  ]);
 
   if (!denom) {
     throw Error("inconsistent database");
@@ -211,10 +211,10 @@ async function storeFailedRefund(
     console.warn("coin not found, can't apply refund");
     return;
   }
-  const denom = await tx.getIndexed(
-    Stores.denominations.denomPubHashIndex,
+  const denom = await tx.get(Stores.denominations, [
+    coin.exchangeBaseUrl,
     coin.denomPubHash,
-  );
+  ]);
 
   if (!denom) {
     throw Error("inconsistent database");
@@ -294,7 +294,8 @@ async function acceptRefunds(
 
         // Still pending.
         if (
-          refundStatus.type === "failure" && !isPermanentFailure &&
+          refundStatus.type === "failure" &&
+          !isPermanentFailure &&
           existingRefundInfo?.type === RefundState.Pending
         ) {
           continue;
diff --git a/packages/taler-wallet-core/src/operations/reserves.ts 
b/packages/taler-wallet-core/src/operations/reserves.ts
index 6db20347..cced6a1d 100644
--- a/packages/taler-wallet-core/src/operations/reserves.ts
+++ b/packages/taler-wallet-core/src/operations/reserves.ts
@@ -172,14 +172,6 @@ export async function createReserve(
     expectedAmount: req.amount,
   });
 
-  const senderWire = req.senderWire;
-  if (senderWire) {
-    const rec = {
-      paytoUri: senderWire,
-    };
-    await ws.db.put(Stores.senderWires, rec);
-  }
-
   const exchangeInfo = await updateExchangeFromUrl(ws, req.exchange);
   const exchangeDetails = exchangeInfo.details;
   if (!exchangeDetails) {
diff --git a/packages/taler-wallet-core/src/operations/tip.ts 
b/packages/taler-wallet-core/src/operations/tip.ts
index 7b914568..08f45eb8 100644
--- a/packages/taler-wallet-core/src/operations/tip.ts
+++ b/packages/taler-wallet-core/src/operations/tip.ts
@@ -104,10 +104,11 @@ export async function prepareTip(
       planchets: undefined,
       createdTimestamp: getTimestampNow(),
       merchantTipId: res.merchantTipId,
-      tipAmountEffective: Amounts.sub(amount, Amounts.add(
-        withdrawDetails.overhead,
-        withdrawDetails.withdrawFee,
-      ).amount).amount,
+      tipAmountEffective: Amounts.sub(
+        amount,
+        Amounts.add(withdrawDetails.overhead, withdrawDetails.withdrawFee)
+          .amount,
+      ).amount,
       retryInfo: initRetryInfo(),
       lastError: undefined,
       denomsSel: denomSelectionInfoToState(selectedDenoms),
@@ -200,10 +201,10 @@ async function processTipImpl(
     const planchets: TipPlanchet[] = [];
 
     for (const sd of denomsForWithdraw.selectedDenoms) {
-      const denom = await ws.db.getIndexed(
-        Stores.denominations.denomPubHashIndex,
+      const denom = await ws.db.get(Stores.denominations, [
+        tipRecord.exchangeBaseUrl,
         sd.denomPubHash,
-      );
+      ]);
       if (!denom) {
         throw Error("denom does not exist anymore");
       }
diff --git a/packages/taler-wallet-core/src/operations/withdraw.ts 
b/packages/taler-wallet-core/src/operations/withdraw.ts
index fd472fdf..e44ac7cf 100644
--- a/packages/taler-wallet-core/src/operations/withdraw.ts
+++ b/packages/taler-wallet-core/src/operations/withdraw.ts
@@ -233,10 +233,10 @@ async function processPlanchetGenerate(
     if (!denomPubHash) {
       throw Error("invariant violated");
     }
-    const denom = await ws.db.getIndexed(
-      Stores.denominations.denomPubHashIndex,
+    const denom = await ws.db.get(Stores.denominations, [
+      withdrawalGroup.exchangeBaseUrl,
       denomPubHash,
-    );
+    ]);
     if (!denom) {
       throw Error("invariant violated");
     }
@@ -325,7 +325,7 @@ async function processPlanchetExchangeRequest(
 
   const denom = await ws.db.get(Stores.denominations, [
     withdrawalGroup.exchangeBaseUrl,
-    planchet.denomPub,
+    planchet.denomPubHash,
   ]);
 
   if (!denom) {
diff --git a/packages/taler-wallet-core/src/types/dbTypes.ts 
b/packages/taler-wallet-core/src/types/dbTypes.ts
index 62eadc78..12a89a43 100644
--- a/packages/taler-wallet-core/src/types/dbTypes.ts
+++ b/packages/taler-wallet-core/src/types/dbTypes.ts
@@ -1383,13 +1383,6 @@ export interface PurchaseRecord {
   autoRefundDeadline: Timestamp | undefined;
 }
 
-/**
- * Information about wire information for bank accounts we withdrew coins from.
- */
-export interface SenderWireRecord {
-  paytoUri: string;
-}
-
 /**
  * Configuration key/value entries to configure
  * the wallet.
@@ -1589,25 +1582,14 @@ class DenominationsStore extends 
Store<DenominationRecord> {
   constructor() {
     // cast needed because of bug in type annotations
     super("denominations", {
-      keyPath: (["exchangeBaseUrl", "denomPub"] as any) as IDBKeyPath,
+      keyPath: (["exchangeBaseUrl", "denomPubHash"] as any) as IDBKeyPath,
     });
   }
-
-  denomPubHashIndex = new Index<string, DenominationRecord>(
-    this,
-    "denomPubHashIndex",
-    "denomPubHash",
-  );
   exchangeBaseUrlIndex = new Index<string, DenominationRecord>(
     this,
     "exchangeBaseUrlIndex",
     "exchangeBaseUrl",
   );
-  denomPubIndex = new Index<string, DenominationRecord>(
-    this,
-    "denomPubIndex",
-    "denomPub",
-  );
 }
 
 class CurrenciesStore extends Store<CurrencyRecord> {
@@ -1640,12 +1622,6 @@ class TipsStore extends Store<TipRecord> {
   }
 }
 
-class SenderWiresStore extends Store<SenderWireRecord> {
-  constructor() {
-    super("senderWires", { keyPath: "paytoUri" });
-  }
-}
-
 class WithdrawalGroupsStore extends Store<WithdrawalGroupRecord> {
   constructor() {
     super("withdrawals", { keyPath: "withdrawalGroupId" });
@@ -1698,7 +1674,6 @@ export const Stores = {
   reserveHistory: new ReserveHistoryStore(),
   purchases: new PurchasesStore(),
   tips: new TipsStore(),
-  senderWires: new SenderWiresStore(),
   withdrawalGroups: new WithdrawalGroupsStore(),
   planchets: new PlanchetsStore(),
   bankWithdrawUris: new BankWithdrawUrisStore(),
diff --git a/packages/taler-wallet-core/src/wallet.ts 
b/packages/taler-wallet-core/src/wallet.ts
index cd964633..e91d74ef 100644
--- a/packages/taler-wallet-core/src/wallet.ts
+++ b/packages/taler-wallet-core/src/wallet.ts
@@ -709,36 +709,6 @@ export class Wallet {
     this.ws.cryptoApi.stop();
   }
 
-  async getSenderWireInfos(): Promise<SenderWireInfos> {
-    const m: { [url: string]: Set<string> } = {};
-
-    await this.db.iter(Stores.exchanges).forEach((x) => {
-      const wi = x.wireInfo;
-      if (!wi) {
-        return;
-      }
-      const s = (m[x.baseUrl] = m[x.baseUrl] || new Set());
-      Object.keys(wi.feesForType).map((k) => s.add(k));
-    });
-
-    const exchangeWireTypes: { [url: string]: string[] } = {};
-    Object.keys(m).map((e) => {
-      exchangeWireTypes[e] = Array.from(m[e]);
-    });
-
-    const senderWiresSet: Set<string> = new Set();
-    await this.db.iter(Stores.senderWires).forEach((x) => {
-      senderWiresSet.add(x.paytoUri);
-    });
-
-    const senderWires: string[] = Array.from(senderWiresSet);
-
-    return {
-      exchangeWireTypes,
-      senderWires,
-    };
-  }
-
   /**
    * Trigger paying coins back into the user's account.
    */
@@ -894,7 +864,7 @@ export class Wallet {
     for (const c of coins) {
       const denom = await this.db.get(Stores.denominations, [
         c.exchangeBaseUrl,
-        c.denomPub,
+        c.denomPubHash,
       ]);
       if (!denom) {
         console.error("no denom session found for coin");

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

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