@optimystic/db-core 1.0.0-beta.2 → 1.0.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/src/cluster/structs.d.ts +62 -16
- package/dist/src/cluster/structs.d.ts.map +1 -1
- package/dist/src/cluster/structs.js +5 -3
- package/dist/src/cluster/structs.js.map +1 -1
- package/dist/src/cohort-topic/antidos/bootstrap-evidence-envelope.d.ts +2 -1
- package/dist/src/cohort-topic/antidos/bootstrap-evidence-envelope.d.ts.map +1 -1
- package/dist/src/cohort-topic/antidos/bootstrap-evidence-envelope.js +10 -3
- package/dist/src/cohort-topic/antidos/bootstrap-evidence-envelope.js.map +1 -1
- package/dist/src/cohort-topic/wire/codec.d.ts.map +1 -1
- package/dist/src/cohort-topic/wire/codec.js +8 -2
- package/dist/src/cohort-topic/wire/codec.js.map +1 -1
- package/dist/src/collection/collection.d.ts +467 -35
- package/dist/src/collection/collection.d.ts.map +1 -1
- package/dist/src/collection/collection.js +879 -149
- package/dist/src/collection/collection.js.map +1 -1
- package/dist/src/collection/struct.d.ts +109 -4
- package/dist/src/collection/struct.d.ts.map +1 -1
- package/dist/src/collection/struct.js +88 -1
- package/dist/src/collection/struct.js.map +1 -1
- package/dist/src/collections/diary/diary.d.ts +6 -2
- package/dist/src/collections/diary/diary.d.ts.map +1 -1
- package/dist/src/collections/diary/diary.js +5 -2
- package/dist/src/collections/diary/diary.js.map +1 -1
- package/dist/src/collections/tree/struct.d.ts +192 -5
- package/dist/src/collections/tree/struct.d.ts.map +1 -1
- package/dist/src/collections/tree/struct.js +134 -0
- package/dist/src/collections/tree/struct.js.map +1 -1
- package/dist/src/collections/tree/tree.d.ts +13 -3
- package/dist/src/collections/tree/tree.d.ts.map +1 -1
- package/dist/src/collections/tree/tree.js +109 -6
- package/dist/src/collections/tree/tree.js.map +1 -1
- package/dist/src/index.d.ts +2 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +2 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/logger-registry.d.ts +57 -0
- package/dist/src/logger-registry.d.ts.map +1 -0
- package/dist/src/logger-registry.js +168 -0
- package/dist/src/logger-registry.js.map +1 -0
- package/dist/src/logger.d.ts.map +1 -1
- package/dist/src/logger.js +3 -0
- package/dist/src/logger.js.map +1 -1
- package/dist/src/matchmaking/wire.d.ts.map +1 -1
- package/dist/src/matchmaking/wire.js +8 -2
- package/dist/src/matchmaking/wire.js.map +1 -1
- package/dist/src/network/durability.d.ts +45 -0
- package/dist/src/network/durability.d.ts.map +1 -0
- package/dist/src/network/durability.js +114 -0
- package/dist/src/network/durability.js.map +1 -0
- package/dist/src/network/i-key-network.d.ts +14 -6
- package/dist/src/network/i-key-network.d.ts.map +1 -1
- package/dist/src/network/index.d.ts +3 -0
- package/dist/src/network/index.d.ts.map +1 -1
- package/dist/src/network/index.js +3 -0
- package/dist/src/network/index.js.map +1 -1
- package/dist/src/network/lineage.d.ts +39 -0
- package/dist/src/network/lineage.d.ts.map +1 -0
- package/dist/src/network/lineage.js +61 -0
- package/dist/src/network/lineage.js.map +1 -0
- package/dist/src/network/routing-key.d.ts +24 -0
- package/dist/src/network/routing-key.d.ts.map +1 -0
- package/dist/src/network/routing-key.js +9 -0
- package/dist/src/network/routing-key.js.map +1 -0
- package/dist/src/network/stale-failure.d.ts +5 -1
- package/dist/src/network/stale-failure.d.ts.map +1 -1
- package/dist/src/network/stale-failure.js +5 -1
- package/dist/src/network/stale-failure.js.map +1 -1
- package/dist/src/network/struct.d.ts +151 -8
- package/dist/src/network/struct.d.ts.map +1 -1
- package/dist/src/network/struct.js.map +1 -1
- package/dist/src/reactivity/wire.d.ts.map +1 -1
- package/dist/src/reactivity/wire.js +8 -2
- package/dist/src/reactivity/wire.js.map +1 -1
- package/dist/src/testing/test-transactor.d.ts +64 -7
- package/dist/src/testing/test-transactor.d.ts.map +1 -1
- package/dist/src/testing/test-transactor.js +150 -23
- package/dist/src/testing/test-transactor.js.map +1 -1
- package/dist/src/transaction/coordinator.d.ts +141 -21
- package/dist/src/transaction/coordinator.d.ts.map +1 -1
- package/dist/src/transaction/coordinator.js +408 -122
- package/dist/src/transaction/coordinator.js.map +1 -1
- package/dist/src/transaction/errors.d.ts +39 -10
- package/dist/src/transaction/errors.d.ts.map +1 -1
- package/dist/src/transaction/errors.js +34 -9
- package/dist/src/transaction/errors.js.map +1 -1
- package/dist/src/transaction/index.d.ts +1 -0
- package/dist/src/transaction/index.d.ts.map +1 -1
- package/dist/src/transaction/index.js.map +1 -1
- package/dist/src/transactor/block-floors.d.ts +78 -0
- package/dist/src/transactor/block-floors.d.ts.map +1 -0
- package/dist/src/transactor/block-floors.js +62 -0
- package/dist/src/transactor/block-floors.js.map +1 -0
- package/dist/src/transactor/change-notifier.d.ts +43 -0
- package/dist/src/transactor/change-notifier.d.ts.map +1 -1
- package/dist/src/transactor/change-notifier.js +3 -0
- package/dist/src/transactor/change-notifier.js.map +1 -1
- package/dist/src/transactor/index.d.ts +1 -0
- package/dist/src/transactor/index.d.ts.map +1 -1
- package/dist/src/transactor/index.js +1 -0
- package/dist/src/transactor/index.js.map +1 -1
- package/dist/src/transactor/network-transactor.d.ts +43 -6
- package/dist/src/transactor/network-transactor.d.ts.map +1 -1
- package/dist/src/transactor/network-transactor.js +279 -81
- package/dist/src/transactor/network-transactor.js.map +1 -1
- package/dist/src/transactor/transactor-source.d.ts +94 -4
- package/dist/src/transactor/transactor-source.d.ts.map +1 -1
- package/dist/src/transactor/transactor-source.js +120 -42
- package/dist/src/transactor/transactor-source.js.map +1 -1
- package/dist/src/transactor/transactor.d.ts +14 -1
- package/dist/src/transactor/transactor.d.ts.map +1 -1
- package/dist/src/transform/atomic.d.ts.map +1 -1
- package/dist/src/transform/atomic.js +12 -9
- package/dist/src/transform/atomic.js.map +1 -1
- package/dist/src/transform/base-pins.d.ts +50 -17
- package/dist/src/transform/base-pins.d.ts.map +1 -1
- package/dist/src/transform/base-pins.js +58 -11
- package/dist/src/transform/base-pins.js.map +1 -1
- package/dist/src/transform/cache-source.d.ts +75 -11
- package/dist/src/transform/cache-source.d.ts.map +1 -1
- package/dist/src/transform/cache-source.js +162 -36
- package/dist/src/transform/cache-source.js.map +1 -1
- package/dist/src/transform/digest.d.ts +8 -1
- package/dist/src/transform/digest.d.ts.map +1 -1
- package/dist/src/transform/digest.js +19 -9
- package/dist/src/transform/digest.js.map +1 -1
- package/dist/src/transform/helpers.d.ts +6 -2
- package/dist/src/transform/helpers.d.ts.map +1 -1
- package/dist/src/transform/helpers.js +8 -3
- package/dist/src/transform/helpers.js.map +1 -1
- package/dist/src/transform/tracker.d.ts +94 -14
- package/dist/src/transform/tracker.d.ts.map +1 -1
- package/dist/src/transform/tracker.js +222 -68
- package/dist/src/transform/tracker.js.map +1 -1
- package/dist/src/utility/structural-equals.d.ts +38 -0
- package/dist/src/utility/structural-equals.d.ts.map +1 -0
- package/dist/src/utility/structural-equals.js +77 -0
- package/dist/src/utility/structural-equals.js.map +1 -0
- package/package.json +2 -2
- package/src/cluster/structs.ts +298 -255
- package/src/cohort-topic/antidos/bootstrap-evidence-envelope.ts +260 -253
- package/src/cohort-topic/wire/codec.ts +222 -216
- package/src/collection/collection.ts +996 -158
- package/src/collection/struct.ts +99 -4
- package/src/collections/diary/diary.ts +71 -68
- package/src/collections/tree/struct.ts +248 -26
- package/src/collections/tree/tree.ts +130 -9
- package/src/index.ts +2 -1
- package/src/logger-registry.ts +224 -0
- package/src/logger.ts +4 -0
- package/src/matchmaking/wire.ts +8 -2
- package/src/network/durability.ts +123 -0
- package/src/network/i-key-network.ts +60 -52
- package/src/network/index.ts +10 -7
- package/src/network/lineage.ts +80 -0
- package/src/network/routing-key.ts +27 -0
- package/src/network/stale-failure.ts +5 -1
- package/src/network/struct.ts +156 -8
- package/src/reactivity/wire.ts +230 -224
- package/src/testing/test-transactor.ts +152 -24
- package/src/transaction/coordinator.ts +470 -131
- package/src/transaction/errors.ts +34 -9
- package/src/transaction/index.ts +1 -0
- package/src/transactor/block-floors.ts +105 -0
- package/src/transactor/change-notifier.ts +129 -80
- package/src/transactor/index.ts +1 -0
- package/src/transactor/network-transactor.ts +297 -84
- package/src/transactor/transactor-source.ts +131 -42
- package/src/transactor/transactor.ts +13 -1
- package/src/transform/atomic.ts +25 -22
- package/src/transform/base-pins.ts +76 -18
- package/src/transform/cache-source.ts +327 -194
- package/src/transform/digest.ts +21 -10
- package/src/transform/helpers.ts +8 -3
- package/src/transform/tracker.ts +423 -270
- package/src/utility/structural-equals.ts +72 -0
- package/dist/src/utility/block-id-to-bytes.d.ts +0 -3
- package/dist/src/utility/block-id-to-bytes.d.ts.map +0 -1
- package/dist/src/utility/block-id-to-bytes.js +0 -7
- package/dist/src/utility/block-id-to-bytes.js.map +0 -1
- package/src/utility/block-id-to-bytes.ts +0 -8
package/dist/src/index.js
CHANGED
|
@@ -6,6 +6,7 @@ export * from "./cohort-topic/index.js";
|
|
|
6
6
|
export * from "./collection/index.js";
|
|
7
7
|
export * from "./collections/index.js";
|
|
8
8
|
export * from "./log/index.js";
|
|
9
|
+
export * from "./logger-registry.js";
|
|
9
10
|
export * from "./matchmaking/index.js";
|
|
10
11
|
export * from "./network/index.js";
|
|
11
12
|
export * from "./reactivity/index.js";
|
|
@@ -17,9 +18,9 @@ export * from "./utility/groupby.js";
|
|
|
17
18
|
export * from "./utility/hash-string.js";
|
|
18
19
|
export * from "./utility/latches.js";
|
|
19
20
|
export * from "./utility/nameof.js";
|
|
21
|
+
export * from "./utility/structural-equals.js";
|
|
20
22
|
export * from "./utility/ensured.js";
|
|
21
23
|
export * from "./utility/pending.js";
|
|
22
|
-
export * from "./utility/block-id-to-bytes.js";
|
|
23
24
|
export * from "./utility/lru-map.js";
|
|
24
25
|
export * from "./utility/backoff.js";
|
|
25
26
|
//# sourceMappingURL=index.js.map
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":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AAC;AACrC,cAAc,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/** The slice of a `debug` module this registry drives. Structural, so db-core never type-imports a particular copy. */
|
|
2
|
+
export interface DebugModule {
|
|
3
|
+
enable(namespaces: string): void;
|
|
4
|
+
/** `debug` 4.x returns the namespaces that were active. */
|
|
5
|
+
disable(): string;
|
|
6
|
+
log: (...args: any[]) => any;
|
|
7
|
+
/**
|
|
8
|
+
* `debug`'s persistence hook, which `enable` calls with every new set: it writes
|
|
9
|
+
* `process.env.DEBUG` on Node and `localStorage.debug` in the browser build. Suppressed around
|
|
10
|
+
* every call this registry makes — see `withoutPersisting`. Optional so a test double need not
|
|
11
|
+
* supply one, and because `@types/debug` does not declare it.
|
|
12
|
+
*/
|
|
13
|
+
save?: (namespaces: string) => void;
|
|
14
|
+
}
|
|
15
|
+
/** Where log lines go — the same shape as `debug`'s own `log` property. */
|
|
16
|
+
export type LogSink = (...args: unknown[]) => void;
|
|
17
|
+
export interface OptimysticLoggingOptions {
|
|
18
|
+
/**
|
|
19
|
+
* Where log lines go. Default: leave each copy's own sink (stderr on Node; `console.debug` in the
|
|
20
|
+
* browser/RN build). Pass one when the platform hides that sink (e.g. a device log filtered above
|
|
21
|
+
* debug level) or to collect a capture in memory.
|
|
22
|
+
*/
|
|
23
|
+
log?: LogSink;
|
|
24
|
+
}
|
|
25
|
+
export interface OptimysticLoggingReport {
|
|
26
|
+
/** The Optimystic contribution, comma-joined — empty when the call enabled nothing. */
|
|
27
|
+
namespaces: string;
|
|
28
|
+
/** One entry per distinct `debug` copy: the packages that registered it. */
|
|
29
|
+
copies: string[][];
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Called once from each package's `src/logger.ts` at module load, with the `debug` module that file
|
|
33
|
+
* imported. Idempotent per (owner, module); several owners sharing one copy are one entry.
|
|
34
|
+
*
|
|
35
|
+
* With no prior `enableOptimysticLogging` call this touches nothing, so `DEBUG=` on Node behaves
|
|
36
|
+
* exactly as it always has. After one, the arriving copy gets the same namespaces and sink at once
|
|
37
|
+
* (its own baseline captured first), silently — the enable call already confirmed.
|
|
38
|
+
*/
|
|
39
|
+
export declare function registerDebugModule(owner: string, module: DebugModule): void;
|
|
40
|
+
/**
|
|
41
|
+
* Turn on the given namespaces on every registered `debug` copy, now and for copies that register
|
|
42
|
+
* later — the way to enable Optimystic logging on any runtime, React Native included, without
|
|
43
|
+
* environment variables.
|
|
44
|
+
*
|
|
45
|
+
* Adds to each copy's existing namespaces rather than replacing them, so an app's own channels
|
|
46
|
+
* sharing a copy stay on. A second call replaces the first call's namespaces and `log`, and does not
|
|
47
|
+
* accumulate. An empty list enables nothing of ours (and is not an error).
|
|
48
|
+
*
|
|
49
|
+
* Always writes one confirmation line — through `options.log` if given, else the first registered
|
|
50
|
+
* copy's sink, else `console.log` — because silence is exactly what cannot be told apart from "the
|
|
51
|
+
* code never ran". No line: this was not called, or the sink is swallowed. A line and no events: the
|
|
52
|
+
* code did not run, or the filter does not match. Events: it works.
|
|
53
|
+
*/
|
|
54
|
+
export declare function enableOptimysticLogging(namespaces: string | readonly string[], options?: OptimysticLoggingOptions): OptimysticLoggingReport;
|
|
55
|
+
/** Undo it: every copy goes back to what it had enabled before the first enable call, and its original sink. Safe to call when nothing is enabled. */
|
|
56
|
+
export declare function disableOptimysticLogging(): void;
|
|
57
|
+
//# sourceMappingURL=logger-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger-registry.d.ts","sourceRoot":"","sources":["../../src/logger-registry.ts"],"names":[],"mappings":"AAkBA,uHAAuH;AACvH,MAAM,WAAW,WAAW;IAC3B,MAAM,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,2DAA2D;IAC3D,OAAO,IAAI,MAAM,CAAC;IAClB,GAAG,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC;IAC7B;;;;;OAKG;IACH,IAAI,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;CACpC;AAED,2EAA2E;AAC3E,MAAM,MAAM,OAAO,GAAG,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;AAEnD,MAAM,WAAW,wBAAwB;IACxC;;;;OAIG;IACH,GAAG,CAAC,EAAE,OAAO,CAAC;CACd;AAED,MAAM,WAAW,uBAAuB;IACvC,uFAAuF;IACvF,UAAU,EAAE,MAAM,CAAC;IACnB,4EAA4E;IAC5E,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC;CACnB;AA4GD;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,IAAI,CAU5E;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,uBAAuB,CACtC,UAAU,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,EACtC,OAAO,CAAC,EAAE,wBAAwB,GAChC,uBAAuB,CAqBzB;AAED,sJAAsJ;AACtJ,wBAAgB,wBAAwB,IAAI,IAAI,CAI/C"}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* One switch for every `optimystic:*` log channel, whichever copy of `debug` it lives on.
|
|
3
|
+
*
|
|
4
|
+
* Why this exists. `debug` turns namespaces on only from `process.env.DEBUG` (Node) or
|
|
5
|
+
* `localStorage.debug` (its browser build, which is the one Metro bundles). React Native has
|
|
6
|
+
* neither, so every channel is silently off there — and an empty capture reads exactly like "that
|
|
7
|
+
* code never ran". Calling `debug.enable(...)` from app code does not fix it reliably either: it
|
|
8
|
+
* reaches only the copy of `debug` the caller resolved, and each Optimystic package may resolve its
|
|
9
|
+
* own (this repo's install, `nmHoistingLimits: workspaces`, gives every package a separate copy).
|
|
10
|
+
*
|
|
11
|
+
* So each package's `src/logger.ts` registers the copy IT imported, and `enableOptimysticLogging`
|
|
12
|
+
* drives all of them. Coverage follows from every package registering, not from how the install
|
|
13
|
+
* happened to be laid out. `docs/debugging.md` § "Turning logging on" is the user-facing statement.
|
|
14
|
+
*
|
|
15
|
+
* This module imports nothing. It sits below every logger in the package, and
|
|
16
|
+
* `test/barrel-import-cycle.spec.ts` holds registry modules to zero runtime imports.
|
|
17
|
+
*/
|
|
18
|
+
/*
|
|
19
|
+
* NOTE: the state lives on `globalThis`, not in module scope, so a bundle that ends up with two
|
|
20
|
+
* copies of db-core still has ONE registry — a copy of a package that registered with the other
|
|
21
|
+
* db-core would otherwise be unreachable. The cost: two DIFFERENT db-core versions in one bundle
|
|
22
|
+
* share this object, so change its shape only additively.
|
|
23
|
+
*/
|
|
24
|
+
const REGISTRY_KEY = Symbol.for('@optimystic/logger-registry');
|
|
25
|
+
function registry() {
|
|
26
|
+
const holder = globalThis;
|
|
27
|
+
return holder[REGISTRY_KEY] ??= { entries: [] };
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Run `fn` with the copy's `save` hook stubbed out, so what we enable changes this process only.
|
|
31
|
+
*
|
|
32
|
+
* Without this, on Node every `enable` would write `process.env.DEBUG` — and a copy of `debug` that
|
|
33
|
+
* loads LATER reads that variable as its own starting set, so it would arrive with our namespaces
|
|
34
|
+
* baked into what `disableOptimysticLogging` later treats as its baseline (they could never be
|
|
35
|
+
* turned off on that copy). Capturing a baseline via `disable()` would also delete the user's
|
|
36
|
+
* `DEBUG`. In a browser, it would persist our namespaces into `localStorage.debug`, leaving logging
|
|
37
|
+
* on after a reload even without this call.
|
|
38
|
+
*/
|
|
39
|
+
function withoutPersisting(module, fn) {
|
|
40
|
+
const save = module.save;
|
|
41
|
+
if (save)
|
|
42
|
+
module.save = () => { };
|
|
43
|
+
try {
|
|
44
|
+
fn();
|
|
45
|
+
}
|
|
46
|
+
finally {
|
|
47
|
+
if (save)
|
|
48
|
+
module.save = save;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Bring one copy in line with `pending`: its baseline (captured on first touch) plus ours, and
|
|
53
|
+
* `pending.log` or its original sink.
|
|
54
|
+
*
|
|
55
|
+
* NOTE: ours is appended, so a `-optimystic:…` skip already in the copy's baseline (say
|
|
56
|
+
* `DEBUG='*,-optimystic:*'`) still wins — `debug` checks skips first. That is the user's explicit
|
|
57
|
+
* exclusion, so it is left alone; if it ever confuses someone, have the confirmation line name the
|
|
58
|
+
* conflicting skip rather than overriding it.
|
|
59
|
+
*
|
|
60
|
+
* NOTE: the baseline is captured once per enable/disable cycle, so an app that calls
|
|
61
|
+
* `debug.enable(...)` on a shared copy while ours are on has that change overwritten by our next
|
|
62
|
+
* enable or disable. Fine while apps set their channels once at start-up; if one ever toggles them
|
|
63
|
+
* at run time, re-derive the baseline from the copy's live set minus our contribution instead.
|
|
64
|
+
*/
|
|
65
|
+
function apply(entry, pending) {
|
|
66
|
+
const module = entry.module;
|
|
67
|
+
if (!entry.original) {
|
|
68
|
+
let namespaces = '';
|
|
69
|
+
withoutPersisting(module, () => { namespaces = module.disable(); });
|
|
70
|
+
entry.original = { namespaces, log: module.log };
|
|
71
|
+
}
|
|
72
|
+
const combined = [entry.original.namespaces, pending.namespaces].filter(Boolean).join(',');
|
|
73
|
+
withoutPersisting(module, () => module.enable(combined));
|
|
74
|
+
module.log = pending.log ?? entry.original.log;
|
|
75
|
+
}
|
|
76
|
+
function restore(entry) {
|
|
77
|
+
const original = entry.original;
|
|
78
|
+
if (!original)
|
|
79
|
+
return;
|
|
80
|
+
withoutPersisting(entry.module, () => entry.module.enable(original.namespaces));
|
|
81
|
+
entry.module.log = original.log;
|
|
82
|
+
entry.original = undefined;
|
|
83
|
+
}
|
|
84
|
+
/** Comma-join, trimming each entry and dropping empty ones. A string may already hold a list. */
|
|
85
|
+
function normalizeNamespaces(namespaces) {
|
|
86
|
+
const parts = typeof namespaces === 'string' ? [namespaces] : namespaces;
|
|
87
|
+
return parts
|
|
88
|
+
.flatMap(part => part.split(','))
|
|
89
|
+
.map(part => part.trim())
|
|
90
|
+
.filter(Boolean)
|
|
91
|
+
.join(',');
|
|
92
|
+
}
|
|
93
|
+
function confirmationLine(report) {
|
|
94
|
+
const what = report.namespaces ? `"${report.namespaces}"` : 'nothing (empty namespace list)';
|
|
95
|
+
const trailer = 'libp2p:* is separate, see docs/debugging.md';
|
|
96
|
+
if (report.copies.length === 0) {
|
|
97
|
+
return `optimystic logging on: ${what}; no debug copies registered yet, namespaces will apply as Optimystic packages load; ${trailer}`;
|
|
98
|
+
}
|
|
99
|
+
const count = report.copies.length;
|
|
100
|
+
const groups = report.copies.map(owners => owners.join(', ')).join(' | ');
|
|
101
|
+
return `optimystic logging on: ${what} across ${count} debug ${count === 1 ? 'copy' : 'copies'} [${groups}]; ${trailer}`;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Called once from each package's `src/logger.ts` at module load, with the `debug` module that file
|
|
105
|
+
* imported. Idempotent per (owner, module); several owners sharing one copy are one entry.
|
|
106
|
+
*
|
|
107
|
+
* With no prior `enableOptimysticLogging` call this touches nothing, so `DEBUG=` on Node behaves
|
|
108
|
+
* exactly as it always has. After one, the arriving copy gets the same namespaces and sink at once
|
|
109
|
+
* (its own baseline captured first), silently — the enable call already confirmed.
|
|
110
|
+
*/
|
|
111
|
+
export function registerDebugModule(owner, module) {
|
|
112
|
+
const state = registry();
|
|
113
|
+
const existing = state.entries.find(entry => entry.module === module);
|
|
114
|
+
if (existing) {
|
|
115
|
+
if (!existing.owners.includes(owner))
|
|
116
|
+
existing.owners.push(owner);
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
const entry = { module, owners: [owner] };
|
|
120
|
+
state.entries.push(entry);
|
|
121
|
+
if (state.pending)
|
|
122
|
+
apply(entry, state.pending);
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Turn on the given namespaces on every registered `debug` copy, now and for copies that register
|
|
126
|
+
* later — the way to enable Optimystic logging on any runtime, React Native included, without
|
|
127
|
+
* environment variables.
|
|
128
|
+
*
|
|
129
|
+
* Adds to each copy's existing namespaces rather than replacing them, so an app's own channels
|
|
130
|
+
* sharing a copy stay on. A second call replaces the first call's namespaces and `log`, and does not
|
|
131
|
+
* accumulate. An empty list enables nothing of ours (and is not an error).
|
|
132
|
+
*
|
|
133
|
+
* Always writes one confirmation line — through `options.log` if given, else the first registered
|
|
134
|
+
* copy's sink, else `console.log` — because silence is exactly what cannot be told apart from "the
|
|
135
|
+
* code never ran". No line: this was not called, or the sink is swallowed. A line and no events: the
|
|
136
|
+
* code did not run, or the filter does not match. Events: it works.
|
|
137
|
+
*/
|
|
138
|
+
export function enableOptimysticLogging(namespaces, options) {
|
|
139
|
+
const state = registry();
|
|
140
|
+
const pending = { namespaces: normalizeNamespaces(namespaces), log: options?.log };
|
|
141
|
+
state.pending = pending;
|
|
142
|
+
for (const entry of state.entries)
|
|
143
|
+
apply(entry, pending);
|
|
144
|
+
const report = {
|
|
145
|
+
namespaces: pending.namespaces,
|
|
146
|
+
copies: state.entries.map(entry => [...entry.owners]),
|
|
147
|
+
};
|
|
148
|
+
const line = confirmationLine(report);
|
|
149
|
+
const sink = options?.log ?? state.entries[0]?.module.log;
|
|
150
|
+
if (sink) {
|
|
151
|
+
sink(line);
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
// No Optimystic package has loaded yet, so there is no debug sink to write through — and the
|
|
155
|
+
// confirmation line must never be skipped (see above).
|
|
156
|
+
// eslint-disable-next-line no-console
|
|
157
|
+
console.log(line);
|
|
158
|
+
}
|
|
159
|
+
return report;
|
|
160
|
+
}
|
|
161
|
+
/** Undo it: every copy goes back to what it had enabled before the first enable call, and its original sink. Safe to call when nothing is enabled. */
|
|
162
|
+
export function disableOptimysticLogging() {
|
|
163
|
+
const state = registry();
|
|
164
|
+
for (const entry of state.entries)
|
|
165
|
+
restore(entry);
|
|
166
|
+
state.pending = undefined;
|
|
167
|
+
}
|
|
168
|
+
//# sourceMappingURL=logger-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"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.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAQzB,wBAAgB,YAAY,CAAC,YAAY,EAAE,MAAM,GAAG,KAAK,CAAC,QAAQ,CAEjE;AAED,eAAO,MAAM,OAAO,SACqE,CAAC"}
|
package/dist/src/logger.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import debug from 'debug';
|
|
2
|
+
import { registerDebugModule } from './logger-registry.js';
|
|
2
3
|
const BASE_NAMESPACE = 'optimystic:db-core';
|
|
4
|
+
// So `enableOptimysticLogging` reaches this package's copy of `debug`, which may be no one else's.
|
|
5
|
+
registerDebugModule('db-core', debug);
|
|
3
6
|
export function createLogger(subNamespace) {
|
|
4
7
|
return debug(`${BASE_NAMESPACE}:${subNamespace}`);
|
|
5
8
|
}
|
package/dist/src/logger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAE1D,MAAM,cAAc,GAAG,oBAAoB,CAAA;AAE3C,mGAAmG;AACnG,mBAAmB,CAAC,SAAS,EAAE,KAAK,CAAC,CAAA;AAErC,MAAM,UAAU,YAAY,CAAC,YAAoB;IAChD,OAAO,KAAK,CAAC,GAAG,cAAc,IAAI,YAAY,EAAE,CAAC,CAAA;AAClD,CAAC;AAED,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,OAAO,KAAK,WAAW;OACjD,CAAC,OAAO,CA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KG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,GAAG,UAAU,CAMvF;AAID;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,KAAK,OAAO,CAAC;AAEzG;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAQlH;AAED,4HAA4H;AAC5H,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAQ9G;AAED;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,IAAI,CAAC,YAAY,EAAE,WAAW,CAAC,GAAG,UAAU,CAgB3F;AAID;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAKhD;AAED;;;;;;GAMG;AACH,wBAAgB,4BAA4B,CAAC,QAAQ,EAAE,IAAI,CAAC,gBAAgB,EAAE,WAAW,GAAG,SAAS,CAAC,GAAG,UAAU,CAWlH"}
|
|
@@ -26,7 +26,10 @@ import { asObject, b64urlField, b64urlFixedLen, COORD_BYTES, failWire as fail, o
|
|
|
26
26
|
import { QUERY_LIMIT_MAX } from "./config.js";
|
|
27
27
|
// --- matchmaking-local wire state (generic validation primitives live in cohort-topic/wire/primitives.js) ---
|
|
28
28
|
const utf8Encoder = new TextEncoder();
|
|
29
|
-
|
|
29
|
+
// Built on first use, not at module load: Hermes (React Native) has no native `TextDecoder`, so a
|
|
30
|
+
// module-scope construction fails the import itself whenever it runs ahead of the host's polyfill.
|
|
31
|
+
let utf8DecoderInstance;
|
|
32
|
+
const utf8Decoder = () => utf8DecoderInstance ??= new TextDecoder("utf-8", { fatal: true });
|
|
30
33
|
/** Ceiling for an opaque app payload (provider/seeker), guarding decode allocation. */
|
|
31
34
|
export const DEFAULT_MAX_APP_PAYLOAD_BYTES = 64 * 1024;
|
|
32
35
|
function validateCapabilityFilter(value, what) {
|
|
@@ -123,9 +126,12 @@ function parseJsonBytes(bytes, maxBytes, what) {
|
|
|
123
126
|
if (bytes.length > maxBytes) {
|
|
124
127
|
fail(`${what}: payload ${bytes.length} exceeds max ${maxBytes} bytes`);
|
|
125
128
|
}
|
|
129
|
+
// Fetched outside the try, so a missing `TextDecoder` polyfill surfaces as itself rather than as
|
|
130
|
+
// "not valid UTF-8".
|
|
131
|
+
const decoder = utf8Decoder();
|
|
126
132
|
let text;
|
|
127
133
|
try {
|
|
128
|
-
text =
|
|
134
|
+
text = decoder.decode(bytes);
|
|
129
135
|
}
|
|
130
136
|
catch {
|
|
131
137
|
fail(`${what}: payload is not valid UTF-8`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wire.js","sourceRoot":"","sources":["../../../src/matchmaking/wire.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EACN,aAAa,EACb,aAAa,EACb,mBAAmB,EACnB,mBAAmB,EACnB,yBAAyB,GACzB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACN,QAAQ,EACR,WAAW,EACX,cAAc,EACd,WAAW,EACX,QAAQ,IAAI,IAAI,EAChB,OAAO,EACP,eAAe,EACf,OAAO,EACP,eAAe,EACf,aAAa,EACb,SAAS,EACT,cAAc,EACd,SAAS,GACT,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAwI9C,+GAA+G;AAE/G,MAAM,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC;AACtC,MAAM,WAAW,GAAG,IAAI,WAAW,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAE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AAE,CAAC,CAAC,CAAC,UAAU,GAAG,CAAC,CAAC,UAAU,IAAI,CAAC,CAAC,UAAU,GAAG,CAAC,CAAC,UAAU,CAAC;SAC1E,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;IACpD,OAAO,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC;QACxC,kBAAkB;QAClB,QAAQ,CAAC,CAAC;QACV,QAAQ,CAAC,OAAO;QAChB,QAAQ,CAAC,WAAW;QACpB,OAAO;KACP,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { BlockId } from "../index.js";
|
|
2
|
+
import type { DurabilityQuorum, WriteDurability } from "./struct.js";
|
|
3
|
+
/**
|
|
4
|
+
* The ONLY "this write is completely saved" test. `quorum === 'full'` alone is not enough: a torn
|
|
5
|
+
* action can have a fully-held tail and blocks that were abandoned and cancelled (`torn`), and a
|
|
6
|
+
* consumer that compared the class by hand would show such a write as saved. Every place that wants
|
|
7
|
+
* to present a change as saved calls this rather than reading the fields.
|
|
8
|
+
*/
|
|
9
|
+
export declare function isFullyDurable(d: WriteDurability): boolean;
|
|
10
|
+
/** Total order on quorum classes: unrouted < local < majority < full. */
|
|
11
|
+
export declare function durabilityRank(q: DurabilityQuorum): number;
|
|
12
|
+
/**
|
|
13
|
+
* Merge per-cohort reports into one action-level report: the weakest becomes the scalar answer and
|
|
14
|
+
* the rest become `otherCohorts`, so a consumer that reads only the scalar fields is reading the
|
|
15
|
+
* binding constraint. `torn` is the union across the inputs — an abandoned block is abandoned
|
|
16
|
+
* whichever cohort it ran on. Reports that already carry `otherCohorts` are flattened first, so
|
|
17
|
+
* merging a merge is the same as merging its inputs. Identical reports collapse to one: a commit
|
|
18
|
+
* sends the tail and the sweep as separate batches, so ONE cohort routinely answers twice for one
|
|
19
|
+
* action, and without this a healthy single-cohort commit would list its own cohort under
|
|
20
|
+
* `otherCohorts`.
|
|
21
|
+
* NOTE: only structurally identical reports collapse. One cohort answering differently for two
|
|
22
|
+
* batches (a member confirmed one block and not the other) appears twice, once per answer, which
|
|
23
|
+
* is the truthful shape. If a consumer ever needs exactly one entry per cohort, fold same-cohort
|
|
24
|
+
* reports here by unioning `unconfirmed`; do not dedupe by `cohortPeerIds` alone.
|
|
25
|
+
*
|
|
26
|
+
* THROWS on an empty input: an action always ran on at least one cohort, and fabricating an answer
|
|
27
|
+
* for one that ran on none is exactly the plain-success ambiguity the durability field removes.
|
|
28
|
+
*/
|
|
29
|
+
export declare function mergeDurability(reports: readonly WriteDurability[]): WriteDurability;
|
|
30
|
+
/**
|
|
31
|
+
* Clamp an action-level report below `full` when the action abandoned blocks. A cohort can hold
|
|
32
|
+
* every block it was asked to commit and the action still be incomplete — the blocks the sweep
|
|
33
|
+
* never reached are on nobody. Never raises the class; a report already below `full` keeps it.
|
|
34
|
+
* Idempotent, and a no-op for an empty `torn`.
|
|
35
|
+
*/
|
|
36
|
+
export declare function withTornBlocks(d: WriteDurability, torn: readonly BlockId[]): WriteDurability;
|
|
37
|
+
/** The single-node answer: this node holds it and knows nothing about a cohort beyond itself. */
|
|
38
|
+
export declare function localDurability(selfPeerId?: string): WriteDurability;
|
|
39
|
+
/**
|
|
40
|
+
* The no-cohort answer: this node holds it and could not establish where it belongs. Takes no
|
|
41
|
+
* reason on purpose: the producing site logs WHY the cohort did not resolve (`CohortResolution.reason`),
|
|
42
|
+
* and the result says only `unrouted`, so no consumer is tempted to branch on prose.
|
|
43
|
+
*/
|
|
44
|
+
export declare function unroutedDurability(): WriteDurability;
|
|
45
|
+
//# sourceMappingURL=durability.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"durability.d.ts","sourceRoot":"","sources":["../../../src/network/durability.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAErE;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,eAAe,GAAG,OAAO,CAE1D;AAED,yEAAyE;AACzE,wBAAgB,cAAc,CAAC,CAAC,EAAE,gBAAgB,GAAG,MAAM,CAO1D;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,SAAS,eAAe,EAAE,GAAG,eAAe,CAgBpF;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,eAAe,EAAE,IAAI,EAAE,SAAS,OAAO,EAAE,GAAG,eAAe,CAQ5F;AAED,iGAAiG;AACjG,wBAAgB,eAAe,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,eAAe,CAOpE;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,IAAI,eAAe,CAEpD"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The ONLY "this write is completely saved" test. `quorum === 'full'` alone is not enough: a torn
|
|
3
|
+
* action can have a fully-held tail and blocks that were abandoned and cancelled (`torn`), and a
|
|
4
|
+
* consumer that compared the class by hand would show such a write as saved. Every place that wants
|
|
5
|
+
* to present a change as saved calls this rather than reading the fields.
|
|
6
|
+
*/
|
|
7
|
+
export function isFullyDurable(d) {
|
|
8
|
+
return d.quorum === 'full' && (d.torn === undefined || d.torn.length === 0);
|
|
9
|
+
}
|
|
10
|
+
/** Total order on quorum classes: unrouted < local < majority < full. */
|
|
11
|
+
export function durabilityRank(q) {
|
|
12
|
+
switch (q) {
|
|
13
|
+
case 'unrouted': return 0;
|
|
14
|
+
case 'local': return 1;
|
|
15
|
+
case 'majority': return 2;
|
|
16
|
+
case 'full': return 3;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Merge per-cohort reports into one action-level report: the weakest becomes the scalar answer and
|
|
21
|
+
* the rest become `otherCohorts`, so a consumer that reads only the scalar fields is reading the
|
|
22
|
+
* binding constraint. `torn` is the union across the inputs — an abandoned block is abandoned
|
|
23
|
+
* whichever cohort it ran on. Reports that already carry `otherCohorts` are flattened first, so
|
|
24
|
+
* merging a merge is the same as merging its inputs. Identical reports collapse to one: a commit
|
|
25
|
+
* sends the tail and the sweep as separate batches, so ONE cohort routinely answers twice for one
|
|
26
|
+
* action, and without this a healthy single-cohort commit would list its own cohort under
|
|
27
|
+
* `otherCohorts`.
|
|
28
|
+
* NOTE: only structurally identical reports collapse. One cohort answering differently for two
|
|
29
|
+
* batches (a member confirmed one block and not the other) appears twice, once per answer, which
|
|
30
|
+
* is the truthful shape. If a consumer ever needs exactly one entry per cohort, fold same-cohort
|
|
31
|
+
* reports here by unioning `unconfirmed`; do not dedupe by `cohortPeerIds` alone.
|
|
32
|
+
*
|
|
33
|
+
* THROWS on an empty input: an action always ran on at least one cohort, and fabricating an answer
|
|
34
|
+
* for one that ran on none is exactly the plain-success ambiguity the durability field removes.
|
|
35
|
+
*/
|
|
36
|
+
export function mergeDurability(reports) {
|
|
37
|
+
const flat = distinctReports(reports.flatMap(flattenDurability));
|
|
38
|
+
if (flat.length === 0) {
|
|
39
|
+
throw new Error('mergeDurability: no durability reports to merge — an action always ran on at least one cohort');
|
|
40
|
+
}
|
|
41
|
+
const ranked = [...flat].sort((a, b) => durabilityRank(a.quorum) - durabilityRank(b.quorum));
|
|
42
|
+
const weakest = ranked[0];
|
|
43
|
+
const others = ranked.slice(1);
|
|
44
|
+
// Over the ORIGINAL reports: flattening strips `torn` (it is action-level), so the union must
|
|
45
|
+
// be taken before that or a torn input merges to an untorn answer.
|
|
46
|
+
const torn = unionTorn(reports);
|
|
47
|
+
return {
|
|
48
|
+
...stripMergedFields(weakest),
|
|
49
|
+
...(others.length === 0 ? {} : { otherCohorts: others.map(stripMergedFields) }),
|
|
50
|
+
...(torn.length === 0 ? {} : { torn })
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Clamp an action-level report below `full` when the action abandoned blocks. A cohort can hold
|
|
55
|
+
* every block it was asked to commit and the action still be incomplete — the blocks the sweep
|
|
56
|
+
* never reached are on nobody. Never raises the class; a report already below `full` keeps it.
|
|
57
|
+
* Idempotent, and a no-op for an empty `torn`.
|
|
58
|
+
*/
|
|
59
|
+
export function withTornBlocks(d, torn) {
|
|
60
|
+
if (torn.length === 0)
|
|
61
|
+
return d;
|
|
62
|
+
const allTorn = Array.from(new Set([...(d.torn ?? []), ...torn]));
|
|
63
|
+
return {
|
|
64
|
+
...d,
|
|
65
|
+
quorum: d.quorum === 'full' ? 'majority' : d.quorum,
|
|
66
|
+
torn: allTorn
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
/** The single-node answer: this node holds it and knows nothing about a cohort beyond itself. */
|
|
70
|
+
export function localDurability(selfPeerId) {
|
|
71
|
+
return {
|
|
72
|
+
quorum: 'local',
|
|
73
|
+
confirmed: 1,
|
|
74
|
+
cohort: 1,
|
|
75
|
+
...(selfPeerId === undefined ? {} : { unconfirmed: [], cohortPeerIds: [selfPeerId] })
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* The no-cohort answer: this node holds it and could not establish where it belongs. Takes no
|
|
80
|
+
* reason on purpose: the producing site logs WHY the cohort did not resolve (`CohortResolution.reason`),
|
|
81
|
+
* and the result says only `unrouted`, so no consumer is tempted to branch on prose.
|
|
82
|
+
*/
|
|
83
|
+
export function unroutedDurability() {
|
|
84
|
+
return { quorum: 'unrouted', confirmed: 1, cohort: 0 };
|
|
85
|
+
}
|
|
86
|
+
/** A merged report's own scalar view plus every `otherCohorts` entry, each as a standalone report. */
|
|
87
|
+
function flattenDurability(d) {
|
|
88
|
+
return [stripMergedFields(d), ...(d.otherCohorts ?? [])];
|
|
89
|
+
}
|
|
90
|
+
/** The per-cohort fields only — `otherCohorts` and `torn` are action-level and re-derived by the merge. */
|
|
91
|
+
function stripMergedFields(d) {
|
|
92
|
+
const { otherCohorts: _otherCohorts, torn: _torn, ...cohortReport } = d;
|
|
93
|
+
return cohortReport;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* First occurrence of each structurally identical per-cohort report, input order kept. Peer lists
|
|
97
|
+
* compare as SETS: `findCluster` orders a cohort by routing distance to the block's key, so one
|
|
98
|
+
* cohort answering for two blocks lists the same members in two orders.
|
|
99
|
+
*/
|
|
100
|
+
function distinctReports(reports) {
|
|
101
|
+
const seen = new Set();
|
|
102
|
+
const sorted = (ids) => ids === undefined ? null : [...ids].sort();
|
|
103
|
+
return reports.filter(r => {
|
|
104
|
+
const key = JSON.stringify([r.quorum, r.confirmed, r.cohort, sorted(r.unconfirmed), sorted(r.cohortPeerIds)]);
|
|
105
|
+
if (seen.has(key))
|
|
106
|
+
return false;
|
|
107
|
+
seen.add(key);
|
|
108
|
+
return true;
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
function unionTorn(reports) {
|
|
112
|
+
return Array.from(new Set(reports.flatMap(r => r.torn ?? [])));
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=durability.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"durability.js","sourceRoot":"","sources":["../../../src/network/durability.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,CAAkB;IAChD,OAAO,CAAC,CAAC,MAAM,KAAK,MAAM,IAAI,CAAC,CAAC,CAAC,IAAI,KAAK,SAAS,IAAI,CAAC,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC;AAC7E,CAAC;AAED,yEAAyE;AACzE,MAAM,UAAU,cAAc,CAAC,CAAmB;IACjD,QAAQ,CAAC,EAAE,CAAC;QACX,KAAK,UAAU,CAAC,CAAC,OAAO,CAAC,CAAC;QAC1B,KAAK,OAAO,CAAC,CAAC,OAAO,CAAC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,eAAe,CAAC,OAAmC;IAC3D,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,MAAM,MAAM,GAAG,CAAC,GAAkC,EAAmB,EAAE,CAAC,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;IACnH,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE;QACzB,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;QAC9G,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;YAAE,OAAO,KAAK,CAAC;QAChC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACd,OAAO,IAAI,CAAC;IACb,CAAC,CAAC,CAAC;AACJ,CAAC;AAED,SAAS,SAAS,CAAC,OAAmC;IACrD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;AAChE,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { PeerId } from "./types.js";
|
|
2
2
|
import type { ClusterPeers } from "../cluster/structs.js";
|
|
3
|
+
import type { RoutingKey } from "./routing-key.js";
|
|
3
4
|
/**
|
|
4
5
|
* What a caller intends to do with the coordinator it is asking for.
|
|
5
6
|
*
|
|
@@ -21,27 +22,34 @@ export type FindCoordinatorOptions = {
|
|
|
21
22
|
*/
|
|
22
23
|
intent?: CoordinatorIntent;
|
|
23
24
|
};
|
|
25
|
+
/**
|
|
26
|
+
* Maps a block to the peers responsible for it.
|
|
27
|
+
*
|
|
28
|
+
* Every key is a {@link RoutingKey} minted by `routingKeyForBlock`. Implementations hash it into a ring
|
|
29
|
+
* coordinate themselves, so a caller must never pre-hash: the writer and the servers agree on a
|
|
30
|
+
* block's cohort only because both hand over the same bytes and exactly one hash is applied to them.
|
|
31
|
+
*/
|
|
24
32
|
export type IKeyNetwork = {
|
|
25
33
|
/**
|
|
26
34
|
* Find a coordinator node responsible for a given key and establish connection
|
|
27
|
-
* @param key The
|
|
35
|
+
* @param key The block's routing key
|
|
28
36
|
* @returns Promise resolving to ID of coordinator node
|
|
29
37
|
*/
|
|
30
|
-
findCoordinator(key:
|
|
38
|
+
findCoordinator(key: RoutingKey, options?: Partial<FindCoordinatorOptions>): Promise<PeerId>;
|
|
31
39
|
/**
|
|
32
40
|
* Find the peers in the cluster responsible for a given key
|
|
33
|
-
* @param key The
|
|
41
|
+
* @param key The block's routing key
|
|
34
42
|
* @returns Promise resolving to the peers in the cluster
|
|
35
43
|
*/
|
|
36
|
-
findCluster(key:
|
|
44
|
+
findCluster(key: RoutingKey): Promise<ClusterPeers>;
|
|
37
45
|
/**
|
|
38
46
|
* Optionally cache a resolved coordinator for a key, so a follow-up operation
|
|
39
47
|
* (e.g. commit after pend) reuses the same peer. Implementations that don't
|
|
40
48
|
* cache coordinators simply omit this. `ttlMs` bounds how long the hint lives.
|
|
41
|
-
* @param key The key the coordinator was resolved for
|
|
49
|
+
* @param key The routing key the coordinator was resolved for — the same key a later `findCoordinator` looks it up by
|
|
42
50
|
* @param peerId The coordinating peer
|
|
43
51
|
* @param ttlMs Optional time-to-live for the cached hint, in ms
|
|
44
52
|
*/
|
|
45
|
-
recordCoordinator?(key:
|
|
53
|
+
recordCoordinator?(key: RoutingKey, peerId: PeerId, ttlMs?: number): void;
|
|
46
54
|
};
|
|
47
55
|
//# sourceMappingURL=i-key-network.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i-key-network.d.ts","sourceRoot":"","sources":["../../../src/network/i-key-network.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"i-key-network.d.ts","sourceRoot":"","sources":["../../../src/network/i-key-network.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD;;;;;;;;GAQG;AACH,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,OAAO,CAAC;AAEjD,MAAM,MAAM,sBAAsB,GAAG;IACpC,sDAAsD;IACtD,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,iBAAiB,CAAC;CAC3B,CAAC;AAGF;;;;;;GAMG;AACH,MAAM,MAAM,WAAW,GAAG;IACzB;;;;OAIG;IACH,eAAe,CAAC,GAAG,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,sBAAsB,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAE7F;;;;OAIG;IACH,WAAW,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;IAEpD;;;;;;;OAOG;IACH,iBAAiB,CAAC,CAAC,GAAG,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1E,CAAA"}
|