@peerbit/shared-log 13.2.24 → 13.2.25
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/checked-prune.d.ts +12 -0
- package/dist/src/checked-prune.d.ts.map +1 -1
- package/dist/src/checked-prune.js +33 -0
- package/dist/src/checked-prune.js.map +1 -1
- package/dist/src/coordinate-persistence.d.ts +211 -0
- package/dist/src/coordinate-persistence.d.ts.map +1 -0
- package/dist/src/coordinate-persistence.js +1133 -0
- package/dist/src/coordinate-persistence.js.map +1 -0
- package/dist/src/errors.d.ts +1 -0
- package/dist/src/errors.d.ts.map +1 -1
- package/dist/src/errors.js +19 -0
- package/dist/src/errors.js.map +1 -1
- package/dist/src/index.d.ts +127 -133
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1400 -4269
- package/dist/src/index.js.map +1 -1
- package/dist/src/instance-lifecycle.d.ts +117 -0
- package/dist/src/instance-lifecycle.d.ts.map +1 -0
- package/dist/src/instance-lifecycle.js +254 -0
- package/dist/src/instance-lifecycle.js.map +1 -0
- package/dist/src/join-warmup.d.ts +86 -0
- package/dist/src/join-warmup.d.ts.map +1 -0
- package/dist/src/join-warmup.js +351 -0
- package/dist/src/join-warmup.js.map +1 -0
- package/dist/src/native-write-through-block-store.d.ts +123 -0
- package/dist/src/native-write-through-block-store.d.ts.map +1 -0
- package/dist/src/native-write-through-block-store.js +989 -0
- package/dist/src/native-write-through-block-store.js.map +1 -0
- package/dist/src/peer-session.d.ts +117 -0
- package/dist/src/peer-session.d.ts.map +1 -0
- package/dist/src/peer-session.js +259 -0
- package/dist/src/peer-session.js.map +1 -0
- package/dist/src/replication-announcement.d.ts +116 -0
- package/dist/src/replication-announcement.d.ts.map +1 -0
- package/dist/src/replication-announcement.js +515 -0
- package/dist/src/replication-announcement.js.map +1 -0
- package/dist/src/replicator-liveness.d.ts +59 -0
- package/dist/src/replicator-liveness.d.ts.map +1 -0
- package/dist/src/replicator-liveness.js +304 -0
- package/dist/src/replicator-liveness.js.map +1 -0
- package/dist/src/sync/dispatch-lifecycle.d.ts +48 -0
- package/dist/src/sync/dispatch-lifecycle.d.ts.map +1 -0
- package/dist/src/sync/dispatch-lifecycle.js +141 -0
- package/dist/src/sync/dispatch-lifecycle.js.map +1 -0
- package/dist/src/sync/factory.d.ts +29 -0
- package/dist/src/sync/factory.d.ts.map +1 -0
- package/dist/src/sync/factory.js +87 -0
- package/dist/src/sync/factory.js.map +1 -0
- package/dist/src/sync/pending-sync-store.d.ts +105 -0
- package/dist/src/sync/pending-sync-store.d.ts.map +1 -0
- package/dist/src/sync/pending-sync-store.js +877 -0
- package/dist/src/sync/pending-sync-store.js.map +1 -0
- package/dist/src/sync/rateless-iblt.d.ts +4 -1
- package/dist/src/sync/rateless-iblt.d.ts.map +1 -1
- package/dist/src/sync/rateless-iblt.js +102 -106
- package/dist/src/sync/rateless-iblt.js.map +1 -1
- package/dist/src/sync/simple.d.ts +10 -41
- package/dist/src/sync/simple.d.ts.map +1 -1
- package/dist/src/sync/simple.js +259 -952
- package/dist/src/sync/simple.js.map +1 -1
- package/dist/src/sync/sync-peer-state.d.ts +16 -0
- package/dist/src/sync/sync-peer-state.d.ts.map +1 -0
- package/dist/src/sync/sync-peer-state.js +82 -0
- package/dist/src/sync/sync-peer-state.js.map +1 -0
- package/package.json +9 -9
- package/src/checked-prune.ts +35 -0
- package/src/coordinate-persistence.ts +1796 -0
- package/src/errors.ts +21 -0
- package/src/index.ts +4014 -7858
- package/src/instance-lifecycle.ts +351 -0
- package/src/join-warmup.ts +507 -0
- package/src/native-write-through-block-store.ts +1170 -0
- package/src/peer-session.ts +336 -0
- package/src/replication-announcement.ts +744 -0
- package/src/replicator-liveness.ts +439 -0
- package/src/sync/dispatch-lifecycle.ts +230 -0
- package/src/sync/factory.ts +154 -0
- package/src/sync/pending-sync-store.ts +1085 -0
- package/src/sync/rateless-iblt.ts +122 -132
- package/src/sync/simple.ts +334 -1144
- package/src/sync/sync-peer-state.ts +107 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// Per-peer sync slot state shared by the simple and rateless synchronizers
|
|
2
|
+
// (stage-4 sync unification). One row per peer carries the response/lookup
|
|
3
|
+
// slot accounting whose release closures may settle long after the peer is
|
|
4
|
+
// gone; both synchronizers use the same registry and the same
|
|
5
|
+
// capture-the-row identity pattern.
|
|
6
|
+
//
|
|
7
|
+
// Per-field lifetime policy (review this table when adding fields):
|
|
8
|
+
//
|
|
9
|
+
// | field | created | cleared |
|
|
10
|
+
// |------------------------------|--------------------|----------------------------|
|
|
11
|
+
// | lookups / responses / active | first slot acquire | physical release settles; |
|
|
12
|
+
// | | | row DETACH only removes |
|
|
13
|
+
// | | | current peer-generation |
|
|
14
|
+
// | | | quota (global quota stays |
|
|
15
|
+
// | | | charged until settlement) |
|
|
16
|
+
// | pendingResponseHashes | consume accepts an | lease release settles |
|
|
17
|
+
// | (simple synchronizer only) | authorization | while attached; row |
|
|
18
|
+
// | | (custody moves | DETACHES at peer |
|
|
19
|
+
// | | batch -> row) | disconnect (budget returns |
|
|
20
|
+
// | | | in aggregate) |
|
|
21
|
+
// | activeReleases | active-response or | logical release settles |
|
|
22
|
+
// | | coordinate | (self-removal); detach |
|
|
23
|
+
// | | dispatch starts | invokes outstanding |
|
|
24
|
+
// | | | logical releases so |
|
|
25
|
+
// | | | retained work drains |
|
|
26
|
+
//
|
|
27
|
+
// Global physical-work accounting deliberately SURVIVES both close()/open()
|
|
28
|
+
// generation rotation and peer disconnect: the underlying storage resolvers
|
|
29
|
+
// and transport sends are not universally abortable, so cross-generation
|
|
30
|
+
// work stays charged until it settles. Disconnect only detaches the row from
|
|
31
|
+
// the current peer generation and releases logical lifecycle ownership.
|
|
32
|
+
//
|
|
33
|
+
// Deliberately host-side this stage (stage-5 folds them into the host peer
|
|
34
|
+
// sessions): dispatch epochs and dispatch-target sets (benchmark-gated hot
|
|
35
|
+
// path), pending-claim rows (owned by the pending-sync record store),
|
|
36
|
+
// admission per-peer indexes (owned by the record store's reservation
|
|
37
|
+
// objects) and the recently-sent exchange-head dedupe rows.
|
|
38
|
+
export class SyncPeerSlotRegistry {
|
|
39
|
+
rows = new Map();
|
|
40
|
+
ensure(peer) {
|
|
41
|
+
let row = this.rows.get(peer);
|
|
42
|
+
if (!row) {
|
|
43
|
+
row = {
|
|
44
|
+
peer,
|
|
45
|
+
attached: true,
|
|
46
|
+
lookups: 0,
|
|
47
|
+
responses: 0,
|
|
48
|
+
active: 0,
|
|
49
|
+
pendingResponseHashes: 0,
|
|
50
|
+
activeReleases: new Set(),
|
|
51
|
+
};
|
|
52
|
+
this.rows.set(peer, row);
|
|
53
|
+
}
|
|
54
|
+
return row;
|
|
55
|
+
}
|
|
56
|
+
// Detaches and returns the peer's row (or undefined when the peer holds no
|
|
57
|
+
// slots). The caller drops only current-generation/per-peer accounting and
|
|
58
|
+
// logical ownership. Physical release closures retain this row by identity
|
|
59
|
+
// and return global quota only when the underlying work actually settles.
|
|
60
|
+
detach(peer) {
|
|
61
|
+
const row = this.rows.get(peer);
|
|
62
|
+
if (!row) {
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
65
|
+
row.attached = false;
|
|
66
|
+
this.rows.delete(peer);
|
|
67
|
+
return row;
|
|
68
|
+
}
|
|
69
|
+
// Rows whose slots all settled while attached are dropped eagerly so the
|
|
70
|
+
// registry never accumulates idle peers between disconnects.
|
|
71
|
+
maybeDropIdle(row) {
|
|
72
|
+
if (row.attached &&
|
|
73
|
+
row.lookups === 0 &&
|
|
74
|
+
row.responses === 0 &&
|
|
75
|
+
row.active === 0 &&
|
|
76
|
+
row.pendingResponseHashes === 0 &&
|
|
77
|
+
row.activeReleases.size === 0) {
|
|
78
|
+
this.rows.delete(row.peer);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=sync-peer-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync-peer-state.js","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AI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAChC,IAAI,CAAC,GAAG,EAAE,CAAC;YACV,OAAO,SAAS,CAAC;QAClB,CAAC;QACD,GAAG,CAAC,QAAQ,GAAG,KAAK,CAAC;QACrB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACvB,OAAO,GAAG,CAAC;IACZ,CAAC;IAED,yEAAyE;IACzE,6DAA6D;IAC7D,aAAa,CAAC,GAAoB;QACjC,IACC,GAAG,CAAC,QAAQ;YACZ,GAAG,CAAC,OAAO,KAAK,CAAC;YACjB,GAAG,CAAC,SAAS,KAAK,CAAC;YACnB,GAAG,CAAC,MAAM,KAAK,CAAC;YAChB,GAAG,CAAC,qBAAqB,KAAK,CAAC;YAC/B,GAAG,CAAC,cAAc,CAAC,IAAI,KAAK,CAAC,EAC5B,CAAC;YACF,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAC5B,CAAC;IACF,CAAC;CACD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@peerbit/shared-log",
|
|
3
|
-
"version": "13.2.
|
|
3
|
+
"version": "13.2.25",
|
|
4
4
|
"description": "Shared log",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"type": "module",
|
|
@@ -62,23 +62,23 @@
|
|
|
62
62
|
"pidusage": "^4.0.1",
|
|
63
63
|
"pino": "^9.4.0",
|
|
64
64
|
"uint8arrays": "^5.1.0",
|
|
65
|
-
"@peerbit/any-store": "2.2.14",
|
|
66
65
|
"@peerbit/blocks-interface": "2.1.5",
|
|
67
|
-
"@peerbit/cache": "3.1.1",
|
|
68
|
-
"@peerbit/blocks": "4.2.10",
|
|
69
66
|
"@peerbit/crypto": "3.1.5",
|
|
70
67
|
"@peerbit/diagnostics": "0.0.1",
|
|
68
|
+
"@peerbit/cache": "3.1.1",
|
|
71
69
|
"@peerbit/indexer-interface": "3.0.9",
|
|
72
70
|
"@peerbit/indexer-sqlite3": "3.0.12",
|
|
73
71
|
"@peerbit/log": "6.2.14",
|
|
74
72
|
"@peerbit/logger": "2.0.1",
|
|
73
|
+
"@peerbit/blocks": "4.2.10",
|
|
75
74
|
"@peerbit/program": "6.0.48",
|
|
75
|
+
"@peerbit/pubsub": "5.4.0",
|
|
76
|
+
"@peerbit/any-store": "2.2.14",
|
|
76
77
|
"@peerbit/pubsub-interface": "5.2.0",
|
|
77
|
-
"@peerbit/riblt": "1.2.0",
|
|
78
78
|
"@peerbit/stream-interface": "6.0.15",
|
|
79
|
+
"@peerbit/rpc": "6.1.16",
|
|
79
80
|
"@peerbit/time": "3.0.1",
|
|
80
|
-
"@peerbit/
|
|
81
|
-
"@peerbit/rpc": "6.1.16"
|
|
81
|
+
"@peerbit/riblt": "1.2.0"
|
|
82
82
|
},
|
|
83
83
|
"optionalDependencies": {
|
|
84
84
|
"@peerbit/native-backbone": "0.2.5",
|
|
@@ -90,8 +90,8 @@
|
|
|
90
90
|
"uuid": "^11.1.1",
|
|
91
91
|
"@peerbit/indexer-rust": "1.0.7",
|
|
92
92
|
"@peerbit/test-utils": "3.1.20",
|
|
93
|
-
"
|
|
94
|
-
"peerbit": "
|
|
93
|
+
"peerbit": "5.3.20",
|
|
94
|
+
"@peerbit/any-store-rust": "0.1.4"
|
|
95
95
|
},
|
|
96
96
|
"repository": {
|
|
97
97
|
"type": "git",
|
package/src/checked-prune.ts
CHANGED
|
@@ -79,6 +79,41 @@ export class CheckedPruneCoordinator<T, R extends "u32" | "u64"> {
|
|
|
79
79
|
private readonly peerRemovalFences = new Map<string, number>();
|
|
80
80
|
private readonly restartReservations = new Map<string, object>();
|
|
81
81
|
private readonly candidateTokens = new Map<string, object>();
|
|
82
|
+
// Moved from SharedLog (same name — the sanctioned file-to-file ratchet
|
|
83
|
+
// move). Depth of checked-prune removals currently holding the ownership
|
|
84
|
+
// lane across a lower-log `log.remove` whose program onChange callback
|
|
85
|
+
// re-enters this instance: while non-zero, invokeProgramOnChange
|
|
86
|
+
// classifies removal-bearing changes as checked-prune-driven. Reset comes
|
|
87
|
+
// free with the per-open coordinator replacement (index.ts open() creates
|
|
88
|
+
// a fresh coordinator); deliberately NOT touched by close() — the release
|
|
89
|
+
// closures drain it, matching the legacy host counter which was reset
|
|
90
|
+
// only at open.
|
|
91
|
+
private _checkedPruneRemoveBlocksLocalRangeMutationAdmission = 0;
|
|
92
|
+
|
|
93
|
+
/** ≡ the legacy inc / `finally`-dec pair around the admitted lower-log
|
|
94
|
+
* remove (old SharedLog site, one synchronous block from the admission
|
|
95
|
+
* checks). The returned release is idempotent and drains THIS coordinator
|
|
96
|
+
* instance — a release that survives into a later open decrements the
|
|
97
|
+
* retired coordinator, never the fresh one (the legacy global counter
|
|
98
|
+
* could go to −1 in that window; unreachable today because close() awaits
|
|
99
|
+
* the prune-remove terminal fence before open() can begin, but the
|
|
100
|
+
* instance scoping makes the proof unnecessary and future-caller-proof). */
|
|
101
|
+
blockLocalRangeMutation(): () => void {
|
|
102
|
+
this._checkedPruneRemoveBlocksLocalRangeMutationAdmission += 1;
|
|
103
|
+
let released = false;
|
|
104
|
+
return () => {
|
|
105
|
+
if (released) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
released = true;
|
|
109
|
+
this._checkedPruneRemoveBlocksLocalRangeMutationAdmission -= 1;
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** ≡ the legacy `counter !== 0` read (site: invokeProgramOnChange). */
|
|
114
|
+
isBlockingLocalRangeMutation(): boolean {
|
|
115
|
+
return this._checkedPruneRemoveBlocksLocalRangeMutationAdmission > 0;
|
|
116
|
+
}
|
|
82
117
|
|
|
83
118
|
private getOrCreateSession(hash: string): CheckedPruneSession<T, R> {
|
|
84
119
|
let session = this.sessions.get(hash);
|