@peerbit/log 4.1.11 → 4.2.0
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/benchmark/payload.js +98 -49
- package/dist/benchmark/payload.js.map +1 -1
- package/dist/src/clock.d.ts +1 -1
- package/dist/src/clock.d.ts.map +1 -1
- package/dist/src/clock.js +165 -115
- package/dist/src/clock.js.map +1 -1
- package/dist/src/entry-index.d.ts.map +1 -1
- package/dist/src/entry-index.js +4 -3
- package/dist/src/entry-index.js.map +1 -1
- package/dist/src/entry-shallow.js +119 -69
- package/dist/src/entry-shallow.js.map +1 -1
- package/dist/src/entry-v0.d.ts.map +1 -1
- package/dist/src/entry-v0.js +451 -381
- package/dist/src/entry-v0.js.map +1 -1
- package/dist/src/entry.d.ts +1 -1
- package/dist/src/heads-cache.d.ts +2 -3
- package/dist/src/heads-cache.d.ts.map +1 -1
- package/dist/src/heads-cache.js +128 -64
- package/dist/src/heads-cache.js.map +1 -1
- package/dist/src/log-sorting.d.ts +1 -1
- package/dist/src/log-sorting.d.ts.map +1 -1
- package/dist/src/log.js +838 -802
- package/dist/src/log.js.map +1 -1
- package/dist/src/logger.d.ts +1 -3
- package/dist/src/logger.d.ts.map +1 -1
- package/dist/src/logger.js +2 -3
- package/dist/src/logger.js.map +1 -1
- package/dist/src/payload.js +80 -43
- package/dist/src/payload.js.map +1 -1
- package/dist/src/snapshot.d.ts +1 -1
- package/dist/src/snapshot.d.ts.map +1 -1
- package/dist/src/snapshot.js +87 -45
- package/dist/src/snapshot.js.map +1 -1
- package/package.json +17 -17
- package/src/clock.ts +1 -5
- package/src/entry-index.ts +5 -3
- package/src/entry-v0.ts +6 -6
- package/src/heads-cache.ts +2 -4
- package/src/log-sorting.ts +1 -1
- package/src/logger.ts +2 -3
- package/src/snapshot.ts +8 -6
package/src/entry-v0.ts
CHANGED
|
@@ -30,10 +30,13 @@ import { ShallowEntry, ShallowMeta } from "./entry-shallow.js";
|
|
|
30
30
|
import { EntryType } from "./entry-type.js";
|
|
31
31
|
import { type CanAppend, Entry } from "./entry.js";
|
|
32
32
|
import type { SortableEntry } from "./log-sorting.js";
|
|
33
|
-
import { logger } from "./logger.js";
|
|
33
|
+
import { logger as baseLogger } from "./logger.js";
|
|
34
34
|
import { Payload } from "./payload.js";
|
|
35
35
|
import { equals } from "./utils.js";
|
|
36
36
|
|
|
37
|
+
const log = baseLogger.newScope("entry-v0");
|
|
38
|
+
const traceLogger = log.trace as typeof log & { enabled?: boolean };
|
|
39
|
+
|
|
37
40
|
export type MaybeEncryptionPublicKey =
|
|
38
41
|
| X25519PublicKey
|
|
39
42
|
| X25519PublicKey[]
|
|
@@ -314,10 +317,10 @@ export class EntryV0<T>
|
|
|
314
317
|
this._signatures!.signatures.map((x) => x.decrypt(this._keychain)),
|
|
315
318
|
);
|
|
316
319
|
|
|
317
|
-
if (
|
|
320
|
+
if ((traceLogger as any)?.enabled) {
|
|
318
321
|
for (const [i, result] of results.entries()) {
|
|
319
322
|
if (result.status === "rejected") {
|
|
320
|
-
|
|
323
|
+
traceLogger("Failed to decrypt signature with index: " + i);
|
|
321
324
|
}
|
|
322
325
|
}
|
|
323
326
|
}
|
|
@@ -474,7 +477,6 @@ export class EntryV0<T>
|
|
|
474
477
|
}
|
|
475
478
|
|
|
476
479
|
const nextHashes: string[] = [];
|
|
477
|
-
let maxChainLength = 0n;
|
|
478
480
|
let gid: string | null = null;
|
|
479
481
|
if (nexts?.length > 0) {
|
|
480
482
|
// take min gid as our gid
|
|
@@ -501,8 +503,6 @@ export class EntryV0<T>
|
|
|
501
503
|
(await EntryV0.createGid(properties.meta?.gidSeed));
|
|
502
504
|
}
|
|
503
505
|
|
|
504
|
-
maxChainLength += 1n; // include this
|
|
505
|
-
|
|
506
506
|
const metadataEncrypted = await maybeEncrypt(
|
|
507
507
|
new Meta({
|
|
508
508
|
clock,
|
package/src/heads-cache.ts
CHANGED
|
@@ -11,11 +11,9 @@ import { logger as loggerFn } from "@peerbit/logger";
|
|
|
11
11
|
import PQueue from "p-queue";
|
|
12
12
|
import path from "path-browserify";
|
|
13
13
|
import { v4 as uuid } from "uuid";
|
|
14
|
-
import type { Entry } from "./entry";
|
|
14
|
+
import type { Entry } from "./entry.js";
|
|
15
15
|
|
|
16
|
-
export const logger
|
|
17
|
-
module: "heads-cache",
|
|
18
|
-
});
|
|
16
|
+
export const logger = loggerFn("peerbit:log:heads-cache");
|
|
19
17
|
export class CachedValue {}
|
|
20
18
|
/* export type AppendOptions<T> = {
|
|
21
19
|
signers?: ((data: Uint8Array) => Promise<SignatureWithKey>)[];
|
package/src/log-sorting.ts
CHANGED
package/src/logger.ts
CHANGED
package/src/snapshot.ts
CHANGED
|
@@ -12,7 +12,9 @@ import { type AnyStore } from "@peerbit/any-store";
|
|
|
12
12
|
import { type Blocks } from "@peerbit/blocks-interface";
|
|
13
13
|
import { waitFor } from "@peerbit/time";
|
|
14
14
|
import { Entry } from "./entry.js";
|
|
15
|
-
import { logger } from "./logger.js";
|
|
15
|
+
import { logger as baseLogger } from "./logger.js";
|
|
16
|
+
|
|
17
|
+
const snapshotLogger = baseLogger.newScope("snapshot");
|
|
16
18
|
|
|
17
19
|
@variant(0)
|
|
18
20
|
export class Snapshot {
|
|
@@ -45,17 +47,17 @@ export const save = async <T>(
|
|
|
45
47
|
snapshotPath: string,
|
|
46
48
|
blockstore: Blocks,
|
|
47
49
|
cache: AnyStore,
|
|
48
|
-
|
|
50
|
+
source: {
|
|
49
51
|
id: Uint8Array;
|
|
50
52
|
getHeads: () => Promise<string[]>;
|
|
51
53
|
getValues: () => Promise<Entry<T>[]> | Entry<T>[];
|
|
52
54
|
},
|
|
53
55
|
): Promise<string> => {
|
|
54
|
-
const values = await
|
|
56
|
+
const values = await source.getValues();
|
|
55
57
|
const buf = serialize(
|
|
56
58
|
new Snapshot({
|
|
57
|
-
id:
|
|
58
|
-
heads: await
|
|
59
|
+
id: source.id,
|
|
60
|
+
heads: await source.getHeads(),
|
|
59
61
|
size: BigInt(values.length),
|
|
60
62
|
values,
|
|
61
63
|
}),
|
|
@@ -71,7 +73,7 @@ export const save = async <T>(
|
|
|
71
73
|
timeout: 10 * 1000,
|
|
72
74
|
});
|
|
73
75
|
|
|
74
|
-
|
|
76
|
+
snapshotLogger.trace(`Saved snapshot: ${snapshot}`);
|
|
75
77
|
return snapshot;
|
|
76
78
|
};
|
|
77
79
|
|