gnunet-svn
[Top][All Lists]
Advanced

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

[taler-wallet-core] branch master updated (28dce57f9 -> 93ab00e60)


From: gnunet
Subject: [taler-wallet-core] branch master updated (28dce57f9 -> 93ab00e60)
Date: Wed, 28 Jun 2023 17:22:35 +0200

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

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

    from 28dce57f9 fix: 7740 check max on p2p push
     new 3f4526847 idb: suggest encoding improvements
     new 93ab00e60 wallet-core: fixup for coin availability (visible coins)

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:
 packages/idb-bridge/src/util/structuredClone.ts    | 38 ++++++++++++++++++----
 packages/taler-wallet-core/src/db.ts               | 15 +++++++--
 .../taler-wallet-core/src/operations/common.ts     |  1 +
 3 files changed, 44 insertions(+), 10 deletions(-)

diff --git a/packages/idb-bridge/src/util/structuredClone.ts 
b/packages/idb-bridge/src/util/structuredClone.ts
index 5ed269db3..a3842b8c4 100644
--- a/packages/idb-bridge/src/util/structuredClone.ts
+++ b/packages/idb-bridge/src/util/structuredClone.ts
@@ -14,6 +14,29 @@
  permissions and limitations under the License.
 */
 
+/**
+ * Encoding (new, compositional version):
+ * 
+ * Encapsulate object that itself might contain a "$" field:
+ * { $: { E... } }
+ * Circular reference:
+ * { $: ["ref", uplevel, field...] }
+ * Date:
+ * { $: ["data"], val: datestr }
+ * Bigint:
+ * { $: ["bigint"], val: bigintstr }
+ * Array with special (non-number) attributes:
+ * { $: ["array"], val: arrayobj }
+ * Undefined field
+ * { $: "undef" }
+ * 
+ * Legacy (top-level only), for backwards compatibility:
+ * { $types: [...] }
+ */
+
+/**
+ * Imports.
+ */
 import { DataCloneError } from "./errors.js";
 
 const { toString: toStr } = {};
@@ -73,10 +96,6 @@ function isUserObject(val: any): boolean {
   return hasConstructorOf(val, Object) || isUserObject(proto);
 }
 
-function isRegExp(val: any): boolean {
-  return toStringTag(val) === "RegExp";
-}
-
 function copyBuffer(cur: any) {
   if (cur instanceof Buffer) {
     return Buffer.from(cur);
@@ -334,8 +353,7 @@ export function structuredEncapsulate(val: any): any {
   return res;
 }
 
-export function internalStructuredRevive(val: any): any {
-  val = JSON.parse(JSON.stringify(val));
+export function applyLegacyTypeAnnotations(val: any): any {
   if (val === null) {
     return null;
   }
@@ -417,8 +435,14 @@ export function internalStructuredRevive(val: any): any {
   return outRoot;
 }
 
+export function internalStructuredRevive(val: any): any {
+  // FIXME: Do the newly specified, compositional encoding here.
+  val = JSON.parse(JSON.stringify(val));
+}
+
 export function structuredRevive(val: any): any {
-  return internalStructuredRevive(val);
+  const r = internalStructuredRevive(val);
+  return applyLegacyTypeAnnotations(r);
 }
 
 /**
diff --git a/packages/taler-wallet-core/src/db.ts 
b/packages/taler-wallet-core/src/db.ts
index 89bb8b053..c12d0f2f7 100644
--- a/packages/taler-wallet-core/src/db.ts
+++ b/packages/taler-wallet-core/src/db.ts
@@ -2152,10 +2152,8 @@ export interface CoinAvailabilityRecord {
    * Number of fresh coins that are available
    * and visible, i.e. the source transaction is in
    * a final state.
-   *
-   * (Optional for backwards compatibility, defaults to 0.)
    */
-  visibleCoinCount?: number;
+  visibleCoinCount: number;
 }
 
 export interface ContractTermsRecord {
@@ -2942,6 +2940,17 @@ export const walletDbFixups: FixupDescription[] = [
       });
     },
   },
+  {
+    name: "CoinAvailabilityRecord_visibleCoinCount_add",
+    async fn(tx): Promise<void> {
+      await tx.coinAvailability.iter().forEachAsync(async (r) => {
+        if (r.visibleCoinCount == null) {
+          r.visibleCoinCount = r.freshCoinCount;
+          await tx.coinAvailability.put(r);
+        }
+      });
+    },
+  },
 ];
 
 const logger = new Logger("db.ts");
diff --git a/packages/taler-wallet-core/src/operations/common.ts 
b/packages/taler-wallet-core/src/operations/common.ts
index 52e4c4b53..620054cae 100644
--- a/packages/taler-wallet-core/src/operations/common.ts
+++ b/packages/taler-wallet-core/src/operations/common.ts
@@ -147,6 +147,7 @@ export async function makeCoinAvailable(
       denomPubHash: denom.denomPubHash,
       exchangeBaseUrl: denom.exchangeBaseUrl,
       freshCoinCount: 0,
+      visibleCoinCount: 0,
     };
   }
   car.freshCoinCount++;

-- 
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]