cojson 0.1.10 → 0.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/base64url.d.ts +2 -0
- package/dist/base64url.js +59 -0
- package/dist/base64url.js.map +1 -0
- package/dist/coValueCore.d.ts +8 -0
- package/dist/coValueCore.js +110 -11
- package/dist/coValueCore.js.map +1 -1
- package/dist/coValues/coStream.d.ts +1 -1
- package/dist/coValues/coStream.js +18 -11
- package/dist/coValues/coStream.js.map +1 -1
- package/dist/crypto.d.ts +3 -3
- package/dist/crypto.js +48 -19
- package/dist/crypto.js.map +1 -1
- package/dist/fastJsonStableStringify.d.ts +1 -0
- package/dist/fastJsonStableStringify.js +53 -0
- package/dist/fastJsonStableStringify.js.map +1 -0
- package/dist/index.d.ts +5 -2
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/dist/sync.js +8 -1
- package/dist/sync.js.map +1 -1
- package/package.json +3 -4
- package/src/account.test.ts +5 -0
- package/src/base64url.test.ts +32 -0
- package/src/base64url.ts +68 -0
- package/src/coValue.test.ts +28 -0
- package/src/coValueCore.test.ts +5 -0
- package/src/coValueCore.ts +158 -15
- package/src/coValues/coStream.ts +31 -16
- package/src/crypto.test.ts +5 -0
- package/src/crypto.ts +59 -22
- package/src/fastJsonStableStringify.ts +54 -0
- package/src/group.test.ts +5 -1
- package/src/index.ts +5 -0
- package/src/permissions.test.ts +5 -1
- package/src/sync.test.ts +6 -6
- package/src/sync.ts +16 -1
package/src/sync.ts
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
WritableStreamDefaultWriter,
|
|
10
10
|
} from "isomorphic-streams";
|
|
11
11
|
import { RawCoID, SessionID } from "./ids.js";
|
|
12
|
+
import { stableStringify } from "./fastJsonStableStringify.js";
|
|
12
13
|
|
|
13
14
|
export type CoValueKnownState = {
|
|
14
15
|
id: RawCoID;
|
|
@@ -445,12 +446,26 @@ export class SyncManager {
|
|
|
445
446
|
const newTransactions =
|
|
446
447
|
newContentForSession.newTransactions.slice(alreadyKnownOffset);
|
|
447
448
|
|
|
448
|
-
const
|
|
449
|
+
const before = performance.now();
|
|
450
|
+
const success = await coValue.tryAddTransactionsAsync(
|
|
449
451
|
sessionID,
|
|
450
452
|
newTransactions,
|
|
451
453
|
undefined,
|
|
452
454
|
newContentForSession.lastSignature
|
|
453
455
|
);
|
|
456
|
+
const after = performance.now();
|
|
457
|
+
if (after - before > 10) {
|
|
458
|
+
const totalTxLength = newTransactions.map(t => stableStringify(t)!.length).reduce((a, b) => a + b, 0);
|
|
459
|
+
console.log(
|
|
460
|
+
"Adding incoming transactions took",
|
|
461
|
+
after - before,
|
|
462
|
+
"ms",
|
|
463
|
+
totalTxLength,
|
|
464
|
+
"bytes = ",
|
|
465
|
+
"bandwidth: MB/s",
|
|
466
|
+
(1000 * totalTxLength / (after - before)) / (1024 * 1024)
|
|
467
|
+
);
|
|
468
|
+
}
|
|
454
469
|
|
|
455
470
|
if (!success) {
|
|
456
471
|
console.error("Failed to add transactions", newTransactions);
|