@optimystic/db-core 1.20.1 → 1.22.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/btree/btree.d.ts +36 -4
- package/dist/src/btree/btree.d.ts.map +1 -1
- package/dist/src/btree/btree.js +86 -18
- package/dist/src/btree/btree.js.map +1 -1
- package/dist/src/cohort-topic/gossip/bus.d.ts +15 -14
- package/dist/src/cohort-topic/gossip/bus.d.ts.map +1 -1
- package/dist/src/cohort-topic/gossip/bus.js +15 -16
- package/dist/src/cohort-topic/gossip/bus.js.map +1 -1
- package/dist/src/cohort-topic/ports.d.ts +30 -4
- package/dist/src/cohort-topic/ports.d.ts.map +1 -1
- package/dist/src/cohort-topic/ports.js +14 -0
- package/dist/src/cohort-topic/ports.js.map +1 -1
- package/dist/src/cohort-topic/registration/renewal.d.ts +27 -1
- package/dist/src/cohort-topic/registration/renewal.d.ts.map +1 -1
- package/dist/src/cohort-topic/registration/renewal.js +15 -4
- package/dist/src/cohort-topic/registration/renewal.js.map +1 -1
- package/dist/src/cohort-topic/service.d.ts +21 -4
- package/dist/src/cohort-topic/service.d.ts.map +1 -1
- package/dist/src/cohort-topic/service.js +208 -18
- package/dist/src/cohort-topic/service.js.map +1 -1
- package/dist/src/cohort-topic/willingness.d.ts +1 -1
- package/dist/src/cohort-topic/willingness.js +1 -1
- package/dist/src/cohort-topic/wire/codec.d.ts +3 -1
- package/dist/src/cohort-topic/wire/codec.d.ts.map +1 -1
- package/dist/src/cohort-topic/wire/codec.js +7 -1
- package/dist/src/cohort-topic/wire/codec.js.map +1 -1
- package/dist/src/cohort-topic/wire/index.d.ts +1 -1
- package/dist/src/cohort-topic/wire/index.d.ts.map +1 -1
- package/dist/src/cohort-topic/wire/index.js +1 -1
- package/dist/src/cohort-topic/wire/index.js.map +1 -1
- package/dist/src/cohort-topic/wire/types.d.ts +17 -1
- package/dist/src/cohort-topic/wire/types.d.ts.map +1 -1
- package/dist/src/cohort-topic/wire/validate.d.ts +15 -1
- package/dist/src/cohort-topic/wire/validate.d.ts.map +1 -1
- package/dist/src/cohort-topic/wire/validate.js +39 -0
- package/dist/src/cohort-topic/wire/validate.js.map +1 -1
- package/dist/src/collection/collection.d.ts +43 -5
- package/dist/src/collection/collection.d.ts.map +1 -1
- package/dist/src/collection/collection.js +60 -13
- package/dist/src/collection/collection.js.map +1 -1
- package/dist/src/collection/struct.d.ts +6 -0
- package/dist/src/collection/struct.d.ts.map +1 -1
- package/dist/src/collection/struct.js.map +1 -1
- package/dist/src/collections/tree/tree.d.ts +3 -1
- package/dist/src/collections/tree/tree.d.ts.map +1 -1
- package/dist/src/collections/tree/tree.js +11 -5
- package/dist/src/collections/tree/tree.js.map +1 -1
- package/dist/src/network/struct.d.ts +15 -0
- package/dist/src/network/struct.d.ts.map +1 -1
- package/dist/src/network/struct.js.map +1 -1
- package/dist/src/testing/test-transactor.js +6 -2
- package/dist/src/testing/test-transactor.js.map +1 -1
- package/dist/src/transaction/coordinator.d.ts +6 -0
- package/dist/src/transaction/coordinator.d.ts.map +1 -1
- package/dist/src/transaction/coordinator.js +6 -0
- package/dist/src/transaction/coordinator.js.map +1 -1
- package/dist/src/transactor/network-transactor.d.ts.map +1 -1
- package/dist/src/transactor/network-transactor.js +1 -0
- package/dist/src/transactor/network-transactor.js.map +1 -1
- package/package.json +1 -1
- package/src/btree/btree.ts +92 -18
- package/src/cohort-topic/gossip/bus.ts +25 -26
- package/src/cohort-topic/ports.ts +31 -4
- package/src/cohort-topic/registration/renewal.ts +40 -5
- package/src/cohort-topic/service.ts +251 -21
- package/src/cohort-topic/willingness.ts +1 -1
- package/src/cohort-topic/wire/codec.ts +12 -0
- package/src/cohort-topic/wire/index.ts +3 -0
- package/src/cohort-topic/wire/types.ts +20 -0
- package/src/cohort-topic/wire/validate.ts +45 -0
- package/src/collection/collection.ts +3098 -3039
- package/src/collection/struct.ts +463 -456
- package/src/collections/tree/tree.ts +15 -7
- package/src/network/struct.ts +770 -755
- package/src/testing/test-transactor.ts +5 -2
- package/src/transaction/coordinator.ts +6 -0
- package/src/transactor/network-transactor.ts +1897 -1896
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* See `docs/cohort-topic.md` §FRET integration and `tickets` slug
|
|
13
13
|
* `cohort-topic-package-layering` for the authoritative layering rule.
|
|
14
14
|
*/
|
|
15
|
-
import type { MembershipCertV1 } from "./wire/types.js";
|
|
15
|
+
import type { CohortGossipV1, MembershipCertV1 } from "./wire/types.js";
|
|
16
16
|
/**
|
|
17
17
|
* Ring coordinate — SHA-256 truncated to the ring width `B` (see {@link IRingHash}). db-core
|
|
18
18
|
* owns this type; db-p2p maps it onto FRET's coordinate type, ensuring the byte representation
|
|
@@ -55,6 +55,14 @@ export interface ITopicRouter {
|
|
|
55
55
|
}): Promise<Uint8Array>;
|
|
56
56
|
/** Direct dial to a cached primary; falls back to {@link routeAndAct} on failure (caller decides). */
|
|
57
57
|
dialMember(member: PeerRef, activity: Uint8Array): Promise<Uint8Array>;
|
|
58
|
+
/**
|
|
59
|
+
* Send an encoded `RenewBatchV1` — several plain renewal pings — to `member` and resolve its encoded
|
|
60
|
+
* `RenewBatchReplyV1`. Rejects with {@link RenewBatchUnsupportedError} when the member does not speak the
|
|
61
|
+
* batch protocol, so the caller can send the same pings singly through {@link dialMember}; any other failure
|
|
62
|
+
* rejects as {@link dialMember}'s does. Optional: a router without it gets no batching, and every ping goes
|
|
63
|
+
* through {@link dialMember}.
|
|
64
|
+
*/
|
|
65
|
+
dialMemberRenewBatch?(member: PeerRef, frame: Uint8Array): Promise<Uint8Array>;
|
|
58
66
|
/**
|
|
59
67
|
* Deliver `activity` to the **root group** of a root-placed topic — the peers responsible for
|
|
60
68
|
* `rootKey` — and return the encoded reply. Optional: the walk uses it for the tier-0 step of a
|
|
@@ -67,6 +75,18 @@ export interface ITopicRouter {
|
|
|
67
75
|
*/
|
|
68
76
|
routeToRoot?(rootKey: Uint8Array, activity: Uint8Array): Promise<Uint8Array>;
|
|
69
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* What {@link ITopicRouter.dialMemberRenewBatch} rejects with when the member does not speak the batch protocol
|
|
80
|
+
* (a build that predates it). That is a definite answer about the member, unlike a link failure, so the pings
|
|
81
|
+
* are re-sent singly rather than counted as failed. A db-core class because db-core cannot see libp2p's errors;
|
|
82
|
+
* the router maps the transport's own refusal onto it.
|
|
83
|
+
*/
|
|
84
|
+
export declare class RenewBatchUnsupportedError extends Error {
|
|
85
|
+
readonly member: Uint8Array;
|
|
86
|
+
constructor(member: Uint8Array, options?: {
|
|
87
|
+
cause?: unknown;
|
|
88
|
+
});
|
|
89
|
+
}
|
|
70
90
|
/**
|
|
71
91
|
* The per-coord rule for a **root-placed** cohort — the root of a topic whose tier-0 coordinate is
|
|
72
92
|
* `H(rootKey)` (see `addressing.ts`). Such a cohort is the group of peers responsible for the root key
|
|
@@ -97,12 +117,18 @@ export interface MembershipLookupOptions {
|
|
|
97
117
|
*/
|
|
98
118
|
readonly rootPlaced?: true;
|
|
99
119
|
}
|
|
100
|
-
/**
|
|
120
|
+
/**
|
|
121
|
+
* Intra-cohort gossip transport (FRET cohort gossip underneath). Outbound frames are encoded by the caller;
|
|
122
|
+
* inbound frames are decoded once by the transport and handed only to the subscribers of the coord they name.
|
|
123
|
+
*/
|
|
101
124
|
export interface ICohortGossipTransport {
|
|
102
125
|
/** Fire-and-forget broadcast of `msg` to the cohort at `coord`. */
|
|
103
126
|
broadcast(coord: RingCoord, msg: Uint8Array): void;
|
|
104
|
-
/**
|
|
105
|
-
|
|
127
|
+
/**
|
|
128
|
+
* Subscribe to inbound cohort gossip naming `coord`; returns an unsubscribe handle. A frame reaches a handler
|
|
129
|
+
* decoded, and, when the transport authenticates frames, only after its signature verified.
|
|
130
|
+
*/
|
|
131
|
+
onGossip(coord: RingCoord, handler: (g: CohortGossipV1) => void): () => void;
|
|
106
132
|
}
|
|
107
133
|
/** Authoritative cohort membership snapshots (FRET `MembershipCertV1` / stabilization underneath). */
|
|
108
134
|
export interface IMembershipSource {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ports.d.ts","sourceRoot":"","sources":["../../../src/cohort-topic/ports.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"ports.d.ts","sourceRoot":"","sources":["../../../src/cohort-topic/ports.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAExE;;;;GAIG;AACH,MAAM,MAAM,SAAS,GAAG,UAAU,CAAC;AAEnC,OAAO,CAAC,MAAM,kBAAkB,EAAE,OAAO,MAAM,CAAC;AAEhD;;;;;;;;;;GAUG;AACH,MAAM,MAAM,aAAa,GAAG,UAAU,GAAG;IAAE,QAAQ,CAAC,CAAC,kBAAkB,CAAC,EAAE,IAAI,CAAA;CAAE,CAAC;AAEjF,gGAAgG;AAChG,MAAM,WAAW,OAAO;IACvB,QAAQ,CAAC,EAAE,EAAE,UAAU,CAAC;CACxB;AAED;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC5B;;;;;OAKG;IACH,WAAW,CAAC,GAAG,EAAE,aAAa,EAAE,QAAQ,EAAE,UAAU,EAAE,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IACrH,sGAAsG;IACtG,UAAU,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IACvE;;;;;;OAMG;IACH,oBAAoB,CAAC,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IAC/E;;;;;;;;;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,CAAC,CAAC,KAAK,EAAE,UAAU,GAAG,SAAS,CAAC;IAChC,0BAA0B;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC1B"}
|
|
@@ -12,6 +12,20 @@
|
|
|
12
12
|
* See `docs/cohort-topic.md` §FRET integration and `tickets` slug
|
|
13
13
|
* `cohort-topic-package-layering` for the authoritative layering rule.
|
|
14
14
|
*/
|
|
15
|
+
/**
|
|
16
|
+
* What {@link ITopicRouter.dialMemberRenewBatch} rejects with when the member does not speak the batch protocol
|
|
17
|
+
* (a build that predates it). That is a definite answer about the member, unlike a link failure, so the pings
|
|
18
|
+
* are re-sent singly rather than counted as failed. A db-core class because db-core cannot see libp2p's errors;
|
|
19
|
+
* the router maps the transport's own refusal onto it.
|
|
20
|
+
*/
|
|
21
|
+
export class RenewBatchUnsupportedError extends Error {
|
|
22
|
+
member;
|
|
23
|
+
constructor(member, options) {
|
|
24
|
+
super("cohort-topic: the member does not speak the renew-batch protocol", options);
|
|
25
|
+
this.member = member;
|
|
26
|
+
this.name = "RenewBatchUnsupportedError";
|
|
27
|
+
}
|
|
28
|
+
}
|
|
15
29
|
/**
|
|
16
30
|
* The db-core default {@link IMembershipTrustAnchor}: it has no local authority over any coord, so it
|
|
17
31
|
* returns `"unknown"` for every cert. Existing verifier callers that inject no anchor get this, keeping
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ports.js","sourceRoot":"","sources":["../../../src/cohort-topic/ports.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;
|
|
1
|
+
{"version":3,"file":"ports.js","sourceRoot":"","sources":["../../../src/cohort-topic/ports.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAkEH;;;;;GAKG;AACH,MAAM,OAAO,0BAA2B,SAAQ,KAAK;IAC/B;IAArB,YAAqB,MAAkB,EAAE,OAA6B;QACrE,KAAK,CAAC,kEAAkE,EAAE,OAAO,CAAC,CAAC;QAD/D,WAAM,GAAN,MAAM,CAAY;QAEtC,IAAI,CAAC,IAAI,GAAG,4BAA4B,CAAC;IAC1C,CAAC;CACD;AAgJD;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAA2B;IAC7D,YAAY,CAAC,KAAuB,EAAE,KAAa,EAAE,UAA0B;QAC9E,OAAO,SAAS,CAAC;IAClB,CAAC;CACD,CAAC"}
|
|
@@ -26,16 +26,42 @@
|
|
|
26
26
|
* rate limit, and a one-off `unknown_registration` from replication lag clears on the next ping.
|
|
27
27
|
* - Cohort-side: evict where `now − lastPing > ttl`; eviction is gossiped so members converge.
|
|
28
28
|
*
|
|
29
|
+
* A participant's cycle has two halves — `preparePing` (sign this cycle's ping and name its primary) and
|
|
30
|
+
* `settlePing` (act on the answer) — so a caller renewing many registrations can send the pings that share a
|
|
31
|
+
* primary in one request (`CohortTopicService.renewMany`) and settle each with its own answer. `pingLoop` is the
|
|
32
|
+
* two halves around one transport send. Re-attaches and withdraws are never split this way: they go singly.
|
|
33
|
+
*
|
|
29
34
|
* Both sides take their transport/gossip by injection so storage + sharding + TTL stay unit-testable
|
|
30
35
|
* in isolation; db-core never imports FRET or libp2p here.
|
|
31
36
|
*/
|
|
32
37
|
import type { RenewReplyV1, RenewV1 } from "../wire/types.js";
|
|
33
38
|
import type { SlotAssigner } from "./sharding.js";
|
|
34
39
|
import type { RegistrationRecord, RegistrationStore } from "./types.js";
|
|
40
|
+
/** One cycle's plain ping, signed and addressed; {@link RenewalParticipant.settlePing} acts on its answer. */
|
|
41
|
+
export interface PreparedPing {
|
|
42
|
+
/** The member the ping goes to: the participant's current primary. */
|
|
43
|
+
readonly target: Uint8Array;
|
|
44
|
+
readonly msg: RenewV1;
|
|
45
|
+
}
|
|
35
46
|
/** Participant-side TTL renewal: periodic ping with 3-fail backup promotion. */
|
|
36
47
|
export interface RenewalParticipant {
|
|
37
|
-
/**
|
|
48
|
+
/**
|
|
49
|
+
* Run one ping cycle: ping the current primary, count failures, promote/relookup as needed. The same as
|
|
50
|
+
* {@link preparePing}, sending the ping through the transport (a rejection is no answer), then {@link settlePing}.
|
|
51
|
+
*/
|
|
38
52
|
pingLoop(): Promise<void>;
|
|
53
|
+
/**
|
|
54
|
+
* The first half of a cycle, for a caller that sends several participants' pings together: this cycle's
|
|
55
|
+
* signed plain ping and the member it goes to. Rejects when the signer does; that is a failed ping, to be
|
|
56
|
+
* settled with no answer.
|
|
57
|
+
*/
|
|
58
|
+
preparePing(): Promise<PreparedPing>;
|
|
59
|
+
/**
|
|
60
|
+
* The second half: act on the prepared ping's answer — `undefined` for none — as {@link pingLoop} does. `ok`
|
|
61
|
+
* resets the failure count, `primary_moved` adopts the named primary, backups and epoch, and anything else
|
|
62
|
+
* is a strike; the third strike in a row fails over, re-attaching to the backups singly and then re-walking.
|
|
63
|
+
*/
|
|
64
|
+
settlePing(reply: RenewReplyV1 | undefined): Promise<void>;
|
|
39
65
|
/** Re-attach to `target` (a backup), carrying the existing record; resolves with the reply. */
|
|
40
66
|
reattach(target: Uint8Array): Promise<RenewReplyV1>;
|
|
41
67
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renewal.d.ts","sourceRoot":"","sources":["../../../../src/cohort-topic/registration/renewal.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"renewal.d.ts","sourceRoot":"","sources":["../../../../src/cohort-topic/registration/renewal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAIH,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAElD,OAAO,KAAK,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAIxE,8GAA8G;AAC9G,MAAM,WAAW,YAAY;IAC5B,sEAAsE;IACtE,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAC5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AAE,CAAC;CAC5D;AAED,2FAA2F;AAC3F,MAAM,WAAW,iBAAiB;IACjC,mHAAmH;IACnH,OAAO,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,YAAY,CAAC;IACjD,kFAAkF;IAClF,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,kBAAkB,EAAE,CAAC;CACvD;AAoLD,yCAAyC;AACzC,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,qBAAqB,GAAG,iBAAiB,CAEtF"}
|
|
@@ -26,6 +26,11 @@
|
|
|
26
26
|
* rate limit, and a one-off `unknown_registration` from replication lag clears on the next ping.
|
|
27
27
|
* - Cohort-side: evict where `now − lastPing > ttl`; eviction is gossiped so members converge.
|
|
28
28
|
*
|
|
29
|
+
* A participant's cycle has two halves — `preparePing` (sign this cycle's ping and name its primary) and
|
|
30
|
+
* `settlePing` (act on the answer) — so a caller renewing many registrations can send the pings that share a
|
|
31
|
+
* primary in one request (`CohortTopicService.renewMany`) and settle each with its own answer. `pingLoop` is the
|
|
32
|
+
* two halves around one transport send. Re-attaches and withdraws are never split this way: they go singly.
|
|
33
|
+
*
|
|
29
34
|
* Both sides take their transport/gossip by injection so storage + sharding + TTL stay unit-testable
|
|
30
35
|
* in isolation; db-core never imports FRET or libp2p here.
|
|
31
36
|
*/
|
|
@@ -55,7 +60,12 @@ class TtlRenewalParticipant {
|
|
|
55
60
|
return pingIntervalMs(this.current.ttl);
|
|
56
61
|
}
|
|
57
62
|
async pingLoop() {
|
|
58
|
-
|
|
63
|
+
await this.settlePing(await this.tryPing());
|
|
64
|
+
}
|
|
65
|
+
async preparePing() {
|
|
66
|
+
return { target: this.current.primary, msg: await this.buildRenew({}) };
|
|
67
|
+
}
|
|
68
|
+
async settlePing(reply) {
|
|
59
69
|
if (reply !== undefined && this.acceptPingReply(reply)) {
|
|
60
70
|
return;
|
|
61
71
|
}
|
|
@@ -75,10 +85,11 @@ class TtlRenewalParticipant {
|
|
|
75
85
|
/* best-effort; the cohort TTL bounds the leak */
|
|
76
86
|
}
|
|
77
87
|
}
|
|
78
|
-
/**
|
|
79
|
-
async
|
|
88
|
+
/** Prepare and send this cycle's ping, mapping a signer or RPC rejection to `undefined` (a counted failure). */
|
|
89
|
+
async tryPing() {
|
|
80
90
|
try {
|
|
81
|
-
|
|
91
|
+
const { target, msg } = await this.preparePing();
|
|
92
|
+
return await this.deps.transport.send(target, msg);
|
|
82
93
|
}
|
|
83
94
|
catch {
|
|
84
95
|
return undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renewal.js","sourceRoot":"","sources":["../../../../src/cohort-topic/registration/renewal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,EAAE,yBAAyB,EAAE,iCAAiC,EAAE,MAAM,4BAA4B,CAAC;AAC1G,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE7D,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAgE/D,MAAM,qBAAqB;IAMgC;IALlD,mBAAmB,GAAG,CAAC,CAAC;IACxB,OAAO,CAAqB;IAC5B,SAAS,CAAyB;IAClC,aAAa,CAAS;IAE9B,YAAY,OAA2B,EAAmB,IAA4B;QAA5B,SAAI,GAAJ,IAAI,CAAwB;QACrF,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,kBAAkB,CAAC;QACzC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC;IACzC,CAAC;IAED,IAAI,MAAM;QACT,OAAO,IAAI,CAAC,OAAO,CAAC;IACrB,CAAC;IAED,IAAI,eAAe;QAClB,OAAO,IAAI,CAAC,SAAS,CAAC;IACvB,CAAC;IAED,IAAI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B,UAAU,EAAE,QAAQ,CAAC,OAAO,CAAC;YAC7B,UAAU,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC;YACjC,WAAW,EAAE,QAAQ,CAAC,WAAW,CAAC;SAClC,CAAC;IACH,CAAC;IAED,UAAU,CAAC,GAAW;QACrB,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;QAChD,KAAK,MAAM,GAAG,IAAI,OAAO,EAAE,CAAC;YAC3B,8FAA8F;YAC9F,6FAA6F;YAC7F,4FAA4F;YAC5F,0DAA0D;YAC1D,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC;YACvE,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAC/B,CAAC;QACD,OAAO,OAAO,CAAC;IAChB,CAAC;CACD;AAED,yCAAyC;AACzC,MAAM,UAAU,uBAAuB,CAAC,IAA2B;IAClE,OAAO,IAAI,sBAAsB,CAAC,IAAI,CAAC,CAAC;AACzC,CAAC;AAED,oFAAoF;AACpF,SAAS,GAAG,CAAC,CAAS;IACrB,OAAO,aAAa,CAAC,CAAC,CAAC,CAAC;AACzB,CAAC"}
|
|
@@ -12,18 +12,25 @@
|
|
|
12
12
|
* a cohort member (`docs/cohort-topic.md` §FRET integration — all four protocols on one node).
|
|
13
13
|
*
|
|
14
14
|
* Composition wired here: {@link WalkEngine} (lookup / register), the `d_max` computer + tier
|
|
15
|
-
* addressing, the participant-side {@link RenewalParticipant} (the `ttl/3` ping with crash-failover
|
|
16
|
-
*
|
|
15
|
+
* addressing, the participant-side {@link RenewalParticipant} (the `ttl/3` ping with crash-failover,
|
|
16
|
+
* whose pings {@link CohortTopicService.renewMany} sends one request per primary), and the application
|
|
17
|
+
* integration hooks ({@link CohortGossipBus}, {@link MembershipVerifier}). The
|
|
17
18
|
* cohort-side modules (willingness, promotion, traffic, store, membership publisher, anti-DoS) are
|
|
18
19
|
* assembled by the member engine the FRET host wires into the `RouteAndMaybeAct` activity callback.
|
|
19
20
|
*/
|
|
20
|
-
import type
|
|
21
|
+
import { type ISizeEstimator, type ITopicRouter, type IRingHash } from "./ports.js";
|
|
21
22
|
import { type RenewalParticipant, type UnsignedRenew } from "./registration/renewal.js";
|
|
22
23
|
import type { CohortGossipBus } from "./gossip/bus.js";
|
|
23
24
|
import type { MembershipVerifier } from "./membership/verifier.js";
|
|
24
25
|
import type { Tier } from "./tiers.js";
|
|
25
26
|
import type { RegisterV1, TopicTrafficV1 } from "./wire/types.js";
|
|
26
27
|
import type { CollectionChangeEvent, CommitCert } from "../transactor/change-notifier.js";
|
|
28
|
+
/**
|
|
29
|
+
* How long a member that refused the renew-batch protocol (a build that predates it) is sent single pings before
|
|
30
|
+
* a batch is tried again: an older member then costs one refused negotiation per interval, and an upgraded one is
|
|
31
|
+
* batched to again within it.
|
|
32
|
+
*/
|
|
33
|
+
export declare const RENEW_BATCH_UNSUPPORTED_RECHECK_MS: number;
|
|
27
34
|
/** A resolved cohort for a topic/tier — the return of {@link CohortTopicService.lookup}. */
|
|
28
35
|
export interface CohortHint {
|
|
29
36
|
readonly topicId: Uint8Array;
|
|
@@ -93,8 +100,18 @@ export interface RegisterRequest {
|
|
|
93
100
|
export interface CohortTopicService {
|
|
94
101
|
/** Walk → register for `topicId` at `tier`; resolves a live {@link RegistrationHandle} or throws {@link CohortBackoffError}. */
|
|
95
102
|
register(req: RegisterRequest): Promise<RegistrationHandle>;
|
|
96
|
-
/** Run one `ttl/3` renewal cycle for `handle` (handles `primary_moved` + crash-failover). */
|
|
103
|
+
/** Run one `ttl/3` renewal cycle for `handle` (handles `primary_moved` + crash-failover): {@link renewMany} of one. */
|
|
97
104
|
renew(handle: RegistrationHandle): Promise<void>;
|
|
105
|
+
/**
|
|
106
|
+
* Run one renewal cycle for each of `handles`, sending the plain pings bound for one member in one request
|
|
107
|
+
* (§TTL and renewal) — singly to a member that does not speak the batch protocol. Each registration is answered
|
|
108
|
+
* and acted on exactly as a single renewal would be. Skipped: a stale or withdrawn handle, and a registration
|
|
109
|
+
* whose previous cycle is still running (usually a failover held up by a re-walk), so no two cycles of one
|
|
110
|
+
* registration run side by side. A handle displaced or withdrawn while its ping was out is not acted on, so it
|
|
111
|
+
* never fails over. Resolves once every cycle has; when some threw, rejects after all of them with that error,
|
|
112
|
+
* or an `AggregateError` of them when several did.
|
|
113
|
+
*/
|
|
114
|
+
renewMany(handles: readonly RegistrationHandle[]): Promise<void>;
|
|
98
115
|
/**
|
|
99
116
|
* Resolve the cohort for `topicId` at `tier` without keeping a live registration. `rootKey` names the
|
|
100
117
|
* root of a root-placed topic (see {@link RegisterRequest.rootKey}).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/cohort-topic/service.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/cohort-topic/service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAMH,OAAO,EAA8B,KAAK,cAAc,EAAE,KAAK,YAAY,EAAE,KAAK,SAAS,EAAgB,MAAM,YAAY,CAAC;AAE9H,OAAO,EAIN,KAAK,kBAAkB,EAEvB,KAAK,aAAa,EAClB,MAAM,2BAA2B,CAAC;AAInC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAGvC,OAAO,KAAK,EAAE,UAAU,EAAuC,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACvG,OAAO,KAAK,EAAE,qBAAqB,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAK1F;;;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AAgB,wBAAwB,CAAC,IAAI,EAAE,sBAAsB,GAAG,kBAAkB,CAEzF"}
|
|
@@ -12,8 +12,9 @@
|
|
|
12
12
|
* a cohort member (`docs/cohort-topic.md` §FRET integration — all four protocols on one node).
|
|
13
13
|
*
|
|
14
14
|
* Composition wired here: {@link WalkEngine} (lookup / register), the `d_max` computer + tier
|
|
15
|
-
* addressing, the participant-side {@link RenewalParticipant} (the `ttl/3` ping with crash-failover
|
|
16
|
-
*
|
|
15
|
+
* addressing, the participant-side {@link RenewalParticipant} (the `ttl/3` ping with crash-failover,
|
|
16
|
+
* whose pings {@link CohortTopicService.renewMany} sends one request per primary), and the application
|
|
17
|
+
* integration hooks ({@link CohortGossipBus}, {@link MembershipVerifier}). The
|
|
17
18
|
* cohort-side modules (willingness, promotion, traffic, store, membership publisher, anti-DoS) are
|
|
18
19
|
* assembled by the member engine the FRET host wires into the `RouteAndMaybeAct` activity callback.
|
|
19
20
|
*/
|
|
@@ -21,12 +22,21 @@ import { randomBytes } from "@noble/hashes/utils.js";
|
|
|
21
22
|
import { createTierAddressing } from "./addressing.js";
|
|
22
23
|
import { makeDMaxComputer } from "./dmax.js";
|
|
23
24
|
import { DEFAULT_FANOUT } from "./addressing.js";
|
|
25
|
+
import { RenewBatchUnsupportedError } from "./ports.js";
|
|
24
26
|
import { createWalkEngine } from "./walk.js";
|
|
25
27
|
import { createRenewalParticipant, } from "./registration/renewal.js";
|
|
26
28
|
import { DEFAULT_TTL_MS } from "./registration/types.js";
|
|
27
|
-
import { recordKey } from "./registration/bytes.js";
|
|
28
|
-
import { bytesToB64url, b64urlToBytes, decodeRenewReplyV1, encodeCohortMessage } from "./wire/codec.js";
|
|
29
|
-
import { MAX_ROOT_KEY_BYTES } from "./wire/validate.js";
|
|
29
|
+
import { bytesKey, recordKey } from "./registration/bytes.js";
|
|
30
|
+
import { bytesToB64url, b64urlToBytes, decodeRenewBatchReplyV1, decodeRenewReplyV1, encodeCohortMessage } from "./wire/codec.js";
|
|
31
|
+
import { CohortWireError, MAX_RENEW_BATCH_ENTRIES, MAX_ROOT_KEY_BYTES } from "./wire/validate.js";
|
|
32
|
+
import { createLogger } from "../logger.js";
|
|
33
|
+
const log = createLogger("cohort-topic:service");
|
|
34
|
+
/**
|
|
35
|
+
* How long a member that refused the renew-batch protocol (a build that predates it) is sent single pings before
|
|
36
|
+
* a batch is tried again: an older member then costs one refused negotiation per interval, and an upgraded one is
|
|
37
|
+
* batched to again within it.
|
|
38
|
+
*/
|
|
39
|
+
export const RENEW_BATCH_UNSUPPORTED_RECHECK_MS = 10 * 60 * 1000;
|
|
30
40
|
/** Thrown when the substrate cannot place a registration right now; carries the back-off delay. */
|
|
31
41
|
export class CohortBackoffError extends Error {
|
|
32
42
|
afterMs;
|
|
@@ -47,6 +57,13 @@ class WalkRegisterService {
|
|
|
47
57
|
maxMessageBytes;
|
|
48
58
|
/** Live renewals, keyed by `(topicId, participantId)` so renew/withdraw/moveRoot find their handle. */
|
|
49
59
|
renewals = new Map();
|
|
60
|
+
/**
|
|
61
|
+
* Members that refused the renew-batch protocol, by `bytesKey`, with the time after which a batch is tried again.
|
|
62
|
+
* NOTE: bounded by the distinct primaries this node renews with, and an entry is dropped only when read after it
|
|
63
|
+
* expires; if a node ever renews with very many distinct primaries, cap it.
|
|
64
|
+
*/
|
|
65
|
+
batchUnsupportedUntil = new Map();
|
|
66
|
+
dialRenewBatch;
|
|
50
67
|
participantId;
|
|
51
68
|
constructor(deps) {
|
|
52
69
|
this.deps = deps;
|
|
@@ -55,6 +72,7 @@ class WalkRegisterService {
|
|
|
55
72
|
this.clock = deps.clock ?? (() => Date.now());
|
|
56
73
|
this.ttl = cfg.ttl ?? DEFAULT_TTL_MS;
|
|
57
74
|
this.maxMessageBytes = cfg.maxMessageBytes;
|
|
75
|
+
this.dialRenewBatch = deps.router.dialMemberRenewBatch?.bind(deps.router);
|
|
58
76
|
// The participant identity carried on the wire (`participantCoord` on register, `participantId`
|
|
59
77
|
// on renew) IS `self` — the dialable peer id db-p2p supplies via its peer-codec. It is the
|
|
60
78
|
// record key the cohort stores AND the signer id its peer-key signature verifies against, so it
|
|
@@ -90,16 +108,25 @@ class WalkRegisterService {
|
|
|
90
108
|
}
|
|
91
109
|
return this.hintFromReply(topicId, tier, outcome, rootKey);
|
|
92
110
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
const
|
|
98
|
-
if (
|
|
111
|
+
renew(handle) {
|
|
112
|
+
return this.renewMany([handle]);
|
|
113
|
+
}
|
|
114
|
+
async renewMany(handles) {
|
|
115
|
+
const cycles = this.beginCycles(handles);
|
|
116
|
+
if (cycles.length === 0) {
|
|
99
117
|
return;
|
|
100
118
|
}
|
|
101
|
-
|
|
102
|
-
|
|
119
|
+
try {
|
|
120
|
+
const pings = await Promise.all(cycles.map((cycle) => this.preparePing(cycle)));
|
|
121
|
+
// Every send finishes before anything is settled, so one registration's failover (re-attaches, then a
|
|
122
|
+
// re-walk) never holds back another's ping.
|
|
123
|
+
const answers = await this.sendPings(pings);
|
|
124
|
+
throwFailures(await this.settleCycles(cycles, answers));
|
|
125
|
+
}
|
|
126
|
+
finally {
|
|
127
|
+
// Each cycle has ended by now, its own settle having ended it; this covers a throw before settling.
|
|
128
|
+
cycles.forEach(endCycle);
|
|
129
|
+
}
|
|
103
130
|
}
|
|
104
131
|
moveRoot(handle, rootKey) {
|
|
105
132
|
assertRootKey(rootKey);
|
|
@@ -150,6 +177,131 @@ class WalkRegisterService {
|
|
|
150
177
|
const live = this.renewals.get(recordKey(handle.topicId, this.participantId));
|
|
151
178
|
return live?.renewal === handle.renewal ? live : undefined;
|
|
152
179
|
}
|
|
180
|
+
/**
|
|
181
|
+
* Mark and return the registrations among `handles` a cycle may run for: live (a stale handle must not drive the
|
|
182
|
+
* registration that displaced it, nor a withdrawn one re-start its pings) and not already renewing. A handle
|
|
183
|
+
* named twice is taken once.
|
|
184
|
+
*/
|
|
185
|
+
beginCycles(handles) {
|
|
186
|
+
const cycles = [];
|
|
187
|
+
for (const handle of handles) {
|
|
188
|
+
const live = this.liveRenewal(handle);
|
|
189
|
+
if (live === undefined || live.cycle !== undefined) {
|
|
190
|
+
continue;
|
|
191
|
+
}
|
|
192
|
+
const cycle = { handle, live };
|
|
193
|
+
live.cycle = cycle;
|
|
194
|
+
cycles.push(cycle);
|
|
195
|
+
}
|
|
196
|
+
return cycles;
|
|
197
|
+
}
|
|
198
|
+
/** The cycle's signed ping, or `undefined` when signing failed — a failed ping, as a single renewal counts it. */
|
|
199
|
+
async preparePing({ handle, live }) {
|
|
200
|
+
try {
|
|
201
|
+
return await live.renewal.preparePing();
|
|
202
|
+
}
|
|
203
|
+
catch (err) {
|
|
204
|
+
log("renew ping for topic %s could not be signed (a failed ping): %o", bytesKey(handle.topicId), err);
|
|
205
|
+
return undefined;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
/** Send every prepared ping and return each one's answer by position, `undefined` for none. Never rejects. */
|
|
209
|
+
async sendPings(pings) {
|
|
210
|
+
const answers = new Array(pings.length).fill(undefined);
|
|
211
|
+
const sends = groupByTarget(pings).flatMap(({ target, positions }) => chunked(positions, MAX_RENEW_BATCH_ENTRIES).map(async (chunk) => {
|
|
212
|
+
const replies = await this.sendToMember(target, chunk.map((position) => pings[position].msg));
|
|
213
|
+
chunk.forEach((position, i) => {
|
|
214
|
+
answers[position] = replies[i];
|
|
215
|
+
});
|
|
216
|
+
}));
|
|
217
|
+
await Promise.all(sends);
|
|
218
|
+
return answers;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Send `msgs` to `target` as one batch frame when that can work, else singly. A member that does not speak the
|
|
222
|
+
* batch protocol is sent the same pings singly at once, and remembered. Any other batch failure — the link, or a
|
|
223
|
+
* reply that is malformed or of the wrong length — is no answer for every ping in it, as the same pings sent
|
|
224
|
+
* singly over that link would each have been. Never rejects.
|
|
225
|
+
*/
|
|
226
|
+
async sendToMember(target, msgs) {
|
|
227
|
+
const dialBatch = this.dialRenewBatch;
|
|
228
|
+
if (msgs.length === 1 || dialBatch === undefined || this.refusedBatches(target)) {
|
|
229
|
+
return this.sendSingly(target, msgs);
|
|
230
|
+
}
|
|
231
|
+
try {
|
|
232
|
+
return await this.sendBatch(dialBatch, target, msgs);
|
|
233
|
+
}
|
|
234
|
+
catch (err) {
|
|
235
|
+
if (err instanceof RenewBatchUnsupportedError) {
|
|
236
|
+
this.batchUnsupportedUntil.set(bytesKey(target), this.clock() + RENEW_BATCH_UNSUPPORTED_RECHECK_MS);
|
|
237
|
+
return this.sendSingly(target, msgs);
|
|
238
|
+
}
|
|
239
|
+
log("renew batch of %d pings to %s got no usable answer (each a failed ping): %o", msgs.length, bytesKey(target), err);
|
|
240
|
+
return msgs.map(() => undefined);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
async sendBatch(dialBatch, target, msgs) {
|
|
244
|
+
const batch = { v: 1, renews: [...msgs] };
|
|
245
|
+
const raw = await dialBatch({ id: target }, encodeCohortMessage(batch, this.maxMessageBytes));
|
|
246
|
+
const { replies } = decodeRenewBatchReplyV1(raw, this.maxMessageBytes);
|
|
247
|
+
if (replies.length !== msgs.length) {
|
|
248
|
+
throw new CohortWireError(`RenewBatchReplyV1: ${replies.length} replies to a batch of ${msgs.length} pings`);
|
|
249
|
+
}
|
|
250
|
+
return replies;
|
|
251
|
+
}
|
|
252
|
+
sendSingly(target, msgs) {
|
|
253
|
+
return Promise.all(msgs.map(async (msg) => {
|
|
254
|
+
try {
|
|
255
|
+
return await this.sendRenew(target, msg);
|
|
256
|
+
}
|
|
257
|
+
catch (err) {
|
|
258
|
+
log("renew ping to %s got no answer (a failed ping): %o", bytesKey(target), err);
|
|
259
|
+
return undefined;
|
|
260
|
+
}
|
|
261
|
+
}));
|
|
262
|
+
}
|
|
263
|
+
/** One renew — ping, re-attach or withdraw — to `target` over the router's direct dial. */
|
|
264
|
+
async sendRenew(target, msg) {
|
|
265
|
+
const raw = await this.deps.router.dialMember({ id: target }, encodeCohortMessage(msg, this.maxMessageBytes));
|
|
266
|
+
return decodeRenewReplyV1(raw, this.maxMessageBytes);
|
|
267
|
+
}
|
|
268
|
+
/** Whether `target` refused the batch protocol within the last {@link RENEW_BATCH_UNSUPPORTED_RECHECK_MS}; an expired entry is dropped. */
|
|
269
|
+
refusedBatches(target) {
|
|
270
|
+
const key = bytesKey(target);
|
|
271
|
+
const until = this.batchUnsupportedUntil.get(key);
|
|
272
|
+
if (until === undefined) {
|
|
273
|
+
return false;
|
|
274
|
+
}
|
|
275
|
+
if (this.clock() < until) {
|
|
276
|
+
return true;
|
|
277
|
+
}
|
|
278
|
+
this.batchUnsupportedUntil.delete(key);
|
|
279
|
+
return false;
|
|
280
|
+
}
|
|
281
|
+
/** Settle every cycle with its answer, side by side; resolves, once all have, with what the ones that threw threw. */
|
|
282
|
+
async settleCycles(cycles, answers) {
|
|
283
|
+
const outcomes = await Promise.allSettled(cycles.map((cycle, i) => this.settleCycle(cycle, answers[i])));
|
|
284
|
+
return outcomes.flatMap((outcome) => (outcome.status === "rejected" ? [outcome.reason] : []));
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Act on one cycle's answer — unless a later register displaced the handle (a tail follow at the root) or it was
|
|
288
|
+
* withdrawn while its ping was out. Settling a displaced registration's strikes would fail it over and re-walk
|
|
289
|
+
* it; its record at the old cohort expires by TTL instead. The cycle ends when this does, not when the slowest
|
|
290
|
+
* cycle of the same call does, so another registration's long failover does not keep this one out of the next call.
|
|
291
|
+
*/
|
|
292
|
+
async settleCycle(cycle, answer) {
|
|
293
|
+
const { handle, live } = cycle;
|
|
294
|
+
try {
|
|
295
|
+
if (this.liveRenewal(handle) !== live) {
|
|
296
|
+
return;
|
|
297
|
+
}
|
|
298
|
+
await live.renewal.settlePing(answer);
|
|
299
|
+
this.syncHandle(handle, live.landing);
|
|
300
|
+
}
|
|
301
|
+
finally {
|
|
302
|
+
endCycle(cycle);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
153
305
|
startRenewal(req, hint, correlationId) {
|
|
154
306
|
const ttl = req.ttl ?? this.ttl;
|
|
155
307
|
const initial = {
|
|
@@ -186,7 +338,7 @@ class WalkRegisterService {
|
|
|
186
338
|
// record still lives at the old one, and a machine in both roots' storage groups holds both; a
|
|
187
339
|
// tombstone resolves through the host's `findHolder`, which picks the newer record there, so it would
|
|
188
340
|
// evict the live registration. The displaced record expires by TTL at its cohort.
|
|
189
|
-
this.renewals.set(recordKey(req.topicId, this.participantId), { renewal, root, landing });
|
|
341
|
+
this.renewals.set(recordKey(req.topicId, this.participantId), { renewal, root, landing, cycle: undefined });
|
|
190
342
|
return renewal;
|
|
191
343
|
}
|
|
192
344
|
/**
|
|
@@ -197,10 +349,7 @@ class WalkRegisterService {
|
|
|
197
349
|
*/
|
|
198
350
|
renewalTransport(req, root, landing) {
|
|
199
351
|
return {
|
|
200
|
-
send:
|
|
201
|
-
const raw = await this.deps.router.dialMember({ id: target }, encodeCohortMessage(msg, this.maxMessageBytes));
|
|
202
|
-
return decodeRenewReplyV1(raw, this.maxMessageBytes);
|
|
203
|
-
},
|
|
352
|
+
send: (target, msg) => this.sendRenew(target, msg),
|
|
204
353
|
relookup: async () => {
|
|
205
354
|
// NOTE: re-sends the first registration's `appPayload` (for a collection watch, its `tailIdAtAttach`
|
|
206
355
|
// and `lastKnownRev`). No cohort reads those fields off a held record today; if one ever does, the
|
|
@@ -314,6 +463,47 @@ function assertRootKey(rootKey) {
|
|
|
314
463
|
throw new RangeError(`cohort-topic: rootKey must be 1..${MAX_ROOT_KEY_BYTES} bytes, got ${rootKey.length}`);
|
|
315
464
|
}
|
|
316
465
|
}
|
|
466
|
+
/** The prepared pings grouped by the member each goes to, in first-seen order; an unprepared one is in no group. */
|
|
467
|
+
function groupByTarget(pings) {
|
|
468
|
+
const groups = new Map();
|
|
469
|
+
pings.forEach((ping, position) => {
|
|
470
|
+
if (ping === undefined) {
|
|
471
|
+
return;
|
|
472
|
+
}
|
|
473
|
+
const key = bytesKey(ping.target);
|
|
474
|
+
const group = groups.get(key);
|
|
475
|
+
if (group !== undefined) {
|
|
476
|
+
group.positions.push(position);
|
|
477
|
+
}
|
|
478
|
+
else {
|
|
479
|
+
groups.set(key, { target: ping.target, positions: [position] });
|
|
480
|
+
}
|
|
481
|
+
});
|
|
482
|
+
return [...groups.values()];
|
|
483
|
+
}
|
|
484
|
+
/** `items` in consecutive runs of at most `size`. */
|
|
485
|
+
function chunked(items, size) {
|
|
486
|
+
const chunks = [];
|
|
487
|
+
for (let i = 0; i < items.length; i += size) {
|
|
488
|
+
chunks.push(items.slice(i, i + size));
|
|
489
|
+
}
|
|
490
|
+
return chunks;
|
|
491
|
+
}
|
|
492
|
+
/** Release the registration `cycle` ran for — only if that cycle still holds it, never a later call's cycle. */
|
|
493
|
+
function endCycle(cycle) {
|
|
494
|
+
if (cycle.live.cycle === cycle) {
|
|
495
|
+
cycle.live.cycle = undefined;
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
/** Rethrow what the settled cycles threw: the one error itself, or an `AggregateError` when several threw. */
|
|
499
|
+
function throwFailures(failures) {
|
|
500
|
+
if (failures.length === 1) {
|
|
501
|
+
throw failures[0];
|
|
502
|
+
}
|
|
503
|
+
if (failures.length > 1) {
|
|
504
|
+
throw new AggregateError(failures, `cohort-topic: ${failures.length} renewal cycles failed`);
|
|
505
|
+
}
|
|
506
|
+
}
|
|
317
507
|
/** Build the participant-facing {@link CohortTopicService} over the injected ports. */
|
|
318
508
|
export function createCohortTopicService(deps) {
|
|
319
509
|
return new WalkRegisterService(deps);
|