@blockcast/mmt-container 0.4.0 → 0.4.1-main.22841c1f0a2d
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/README.md +37 -21
- package/dist/align.d.ts +24 -18
- package/dist/align.d.ts.map +1 -1
- package/dist/align.js +23 -4
- package/dist/align.js.map +2 -2
- package/dist/browser-runtime.js +2037 -881
- package/dist/browser-runtime.js.map +4 -4
- package/dist/carp-catalog.d.ts +76 -39
- package/dist/carp-catalog.d.ts.map +1 -1
- package/dist/carp-catalog.js +321 -205
- package/dist/carp-catalog.js.map +3 -3
- package/dist/catalog-fec-params.d.ts +12 -4
- package/dist/catalog-fec-params.d.ts.map +1 -1
- package/dist/catalog-fec-params.js +40 -17
- package/dist/catalog-fec-params.js.map +3 -3
- package/dist/catalog-network-source.d.ts +28 -7
- package/dist/catalog-network-source.d.ts.map +1 -1
- package/dist/catalog-network-source.js +21 -1
- package/dist/catalog-network-source.js.map +2 -2
- package/dist/catalog-validator.d.ts +4 -3
- package/dist/catalog-validator.d.ts.map +1 -1
- package/dist/catalog-validator.js +0 -29
- package/dist/catalog-validator.js.map +3 -3
- package/dist/cmcd-producer.d.ts +13 -1
- package/dist/cmcd-producer.d.ts.map +1 -1
- package/dist/cmcd-producer.js +14 -0
- package/dist/cmcd-producer.js.map +2 -2
- package/dist/delivery-catalog.js +98 -234
- package/dist/delivery-catalog.js.map +4 -4
- package/dist/fec-manager.d.ts +108 -1
- package/dist/fec-manager.d.ts.map +1 -1
- package/dist/fec-manager.js +452 -66
- package/dist/fec-manager.js.map +4 -4
- package/dist/fec-state.d.ts +2 -1
- package/dist/fec-state.d.ts.map +1 -1
- package/dist/fec-state.js +18 -3
- package/dist/fec-state.js.map +3 -3
- package/dist/fec-worker-setup.d.ts +10 -0
- package/dist/fec-worker-setup.d.ts.map +1 -1
- package/dist/fec-worker-setup.js +15 -4
- package/dist/fec-worker-setup.js.map +2 -2
- package/dist/held-layer-admission.d.ts +58 -0
- package/dist/held-layer-admission.d.ts.map +1 -0
- package/dist/held-layer-admission.js +105 -0
- package/dist/held-layer-admission.js.map +7 -0
- package/dist/index.d.ts +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -8
- package/dist/index.js.map +2 -2
- package/dist/iso-block-locator.d.ts +39 -1
- package/dist/iso-block-locator.d.ts.map +1 -1
- package/dist/iso-block-locator.js +109 -17
- package/dist/iso-block-locator.js.map +3 -3
- package/dist/mfu-reassembler.js +21 -13
- package/dist/mfu-reassembler.js.map +2 -2
- package/dist/mmtp-container-parser.d.ts.map +1 -1
- package/dist/mmtp-container-parser.js +93 -22
- package/dist/mmtp-container-parser.js.map +2 -2
- package/dist/mmtp-container-parser.no-modules.js +3677 -1213
- package/dist/mmtp-container-parser.no-modules.js.map +4 -4
- package/dist/mmtp-decode-pipeline.js +93 -22
- package/dist/mmtp-decode-pipeline.js.map +2 -2
- package/dist/mmtp-fec-session.d.ts +192 -0
- package/dist/mmtp-fec-session.d.ts.map +1 -0
- package/dist/mmtp-fec-session.js +640 -0
- package/dist/mmtp-fec-session.js.map +7 -0
- package/dist/mmtp-router.d.ts +69 -32
- package/dist/mmtp-router.d.ts.map +1 -1
- package/dist/mmtp-router.js +296 -192
- package/dist/mmtp-router.js.map +2 -2
- package/dist/multicast-auth-catalog.d.ts +86 -92
- package/dist/multicast-auth-catalog.d.ts.map +1 -1
- package/dist/multicast-auth-catalog.js +313 -124
- package/dist/multicast-auth-catalog.js.map +3 -3
- package/dist/multicast-input.d.ts +31 -8
- package/dist/multicast-input.d.ts.map +1 -1
- package/dist/multicast-input.js +299 -35
- package/dist/multicast-input.js.map +3 -3
- package/dist/multicast-manager.d.ts +97 -11
- package/dist/multicast-manager.d.ts.map +1 -1
- package/dist/multicast-manager.js +1022 -527
- package/dist/multicast-manager.js.map +4 -4
- package/dist/multicast-transport.d.ts +12 -2
- package/dist/multicast-transport.d.ts.map +1 -1
- package/dist/multicast-transport.js +108 -238
- package/dist/multicast-transport.js.map +4 -4
- package/dist/multicast-unwrap.js +21 -13
- package/dist/multicast-unwrap.js.map +2 -2
- package/dist/no-modules.d.ts +5 -3
- package/dist/no-modules.d.ts.map +1 -1
- package/dist/no-modules.js +3625 -1194
- package/dist/no-modules.js.map +4 -4
- package/dist/phase14-catalog-override.d.ts +1 -1
- package/dist/phase14-catalog-override.d.ts.map +1 -1
- package/dist/phase14-catalog-override.js +2 -2
- package/dist/phase14-catalog-override.js.map +2 -2
- package/dist/repair-fetch.d.ts +81 -6
- package/dist/repair-fetch.d.ts.map +1 -1
- package/dist/repair-fetch.js +156 -31
- package/dist/repair-fetch.js.map +3 -3
- package/dist/repair-layers.d.ts +2 -0
- package/dist/repair-layers.d.ts.map +1 -1
- package/dist/repair-layers.js +19 -2
- package/dist/repair-layers.js.map +2 -2
- package/dist/sample-combiner.d.ts +7 -1
- package/dist/sample-combiner.d.ts.map +1 -1
- package/dist/sample-combiner.js +14 -2
- package/dist/sample-combiner.js.map +2 -2
- package/dist/signaling.d.ts +2 -2
- package/dist/signaling.d.ts.map +1 -1
- package/dist/signaling.js +3 -3
- package/dist/signaling.js.map +2 -2
- package/dist/switching-set-alignment.d.ts +1 -1
- package/dist/switching-set-alignment.js.map +1 -1
- package/dist/timestamp-codec.js +21 -13
- package/dist/timestamp-codec.js.map +2 -2
- package/dist/wasm-mfu-reassembler.js.map +1 -1
- package/dist/wasm-mmtp-container-parser.js +93 -22
- package/dist/wasm-mmtp-container-parser.js.map +2 -2
- package/package.json +6 -18
- package/schemas/catalog.schema.json +133 -38
- package/src/align.ts +52 -21
- package/src/carp-catalog.ts +188 -68
- package/src/catalog-fec-params.ts +28 -3
- package/src/catalog-network-source.ts +49 -7
- package/src/catalog-validator.ts +4 -11
- package/src/cmcd-producer.ts +23 -1
- package/src/fec-manager.ts +366 -63
- package/src/fec-state.ts +11 -4
- package/src/fec-worker-setup.ts +30 -2
- package/src/held-layer-admission.ts +161 -0
- package/src/index.ts +32 -19
- package/src/iso-block-locator.ts +110 -7
- package/src/mmtp-container-parser.ts +75 -7
- package/src/mmtp-fec-session.ts +606 -0
- package/src/mmtp-router.ts +301 -240
- package/src/multicast-auth-catalog.ts +134 -238
- package/src/multicast-input.ts +148 -124
- package/src/multicast-manager.ts +271 -40
- package/src/multicast-transport.ts +17 -3
- package/src/no-modules.ts +8 -7
- package/src/phase14-catalog-override.ts +3 -3
- package/src/repair-fetch.ts +283 -39
- package/src/repair-layers.ts +22 -2
- package/src/sample-combiner.ts +15 -2
- package/src/signaling.ts +2 -2
- package/src/switching-set-alignment.ts +1 -1
- package/test-vectors/align.json +108 -32
- package/test-vectors/bc-provenance-v2.json +1526 -0
- package/test-vectors/catalog/README.md +71 -4
- package/test-vectors/catalog/negative/fec-block-profile-missing.json +1 -1
- package/test-vectors/catalog/negative/fec-block-profile-retired.json +1 -1
- package/test-vectors/catalog/negative/fec-block-profile-unknown.json +1 -1
- package/test-vectors/catalog/negative/fec-iso-symbol-size-below-floor.json +28 -0
- package/test-vectors/catalog/negative/fec-reed-solomon-iso-symbol-size-13.json +28 -0
- package/test-vectors/catalog/negative/fec-reed-solomon-k-plus-p-over-255.json +39 -0
- package/test-vectors/catalog/negative/fec-reed-solomon-overlay-over-255.json +40 -0
- package/test-vectors/catalog/negative/fec-repair-overlay-source-symbols-zero.json +43 -0
- package/test-vectors/catalog/negative/fec-repair-symbols-zero.json +28 -0
- package/test-vectors/catalog/negative/fec-source-symbols-zero.json +28 -0
- package/test-vectors/catalog/negative/fec-symbol-size-zero.json +28 -0
- package/test-vectors/catalog/negative/init-data-inline-without-data.json +22 -0
- package/test-vectors/catalog/negative/mmtp-mode-mpu.json +15 -0
- package/test-vectors/catalog/negative/multicast-amt-dns-without-relay.json +37 -0
- package/test-vectors/catalog/negative/multicast-amt-driad-with-relay.json +38 -0
- package/test-vectors/catalog/negative/multicast-auth-asm-missing-sender-address.json +77 -0
- package/test-vectors/catalog/negative/multicast-auth-duplicate-first-epoch.json +56 -0
- package/test-vectors/catalog/negative/multicast-auth-duplicate-kid.json +56 -0
- package/test-vectors/catalog/negative/multicast-auth-endpoint-auth-without-object-auth.json +38 -0
- package/test-vectors/catalog/negative/multicast-auth-endpoint-missing-auth.json +49 -0
- package/test-vectors/catalog/negative/multicast-auth-endpoint-missing-bandwidth.json +55 -0
- package/test-vectors/catalog/negative/multicast-auth-manifest-port-equals-port.json +56 -0
- package/test-vectors/catalog/negative/multicast-auth-manifest-timer-out-of-range.json +56 -0
- package/test-vectors/catalog/negative/multicast-auth-max-auth-delay-above-max.json +56 -0
- package/test-vectors/catalog/negative/multicast-auth-max-auth-delay-below-min.json +56 -0
- package/test-vectors/catalog/negative/multicast-auth-root-dotted-key.json +55 -0
- package/test-vectors/catalog/negative/multicast-auth-sender-address-on-ssm.json +57 -0
- package/test-vectors/catalog/negative/multicast-auth-version-1.json +56 -0
- package/test-vectors/catalog/negative/multicast-auth-version-3.json +56 -0
- package/test-vectors/catalog/negative/multicast-auth-version-missing.json +55 -0
- package/test-vectors/catalog/negative/multicast-endpoint-foreign-namespace-track.json +44 -0
- package/test-vectors/catalog/negative/multicast-endpoint-protocol-amt.json +38 -0
- package/test-vectors/catalog/negative/multicast-endpoint-protocol-atsc3.json +38 -0
- package/test-vectors/catalog/negative/presentation-anchor-unsafe.json +16 -0
- package/test-vectors/catalog/positive/fec-algorithm-unimplemented.json +29 -0
- package/test-vectors/catalog/positive/fec-iso-ssbg1.json +1 -1
- package/test-vectors/catalog/positive/fec-multicast.json +1 -1
- package/test-vectors/catalog/positive/fec-reed-solomon-layered.json +50 -0
- package/test-vectors/catalog/positive/mmt01-12-1-init-ref-anchor.json +29 -0
- package/test-vectors/catalog/positive/multicast-amt-discovery-omitted.json +37 -0
- package/test-vectors/catalog/positive/multicast-amt-dns-relay.json +38 -0
- package/test-vectors/catalog/positive/multicast-amt-manual-relay.json +3 -3
- package/test-vectors/catalog/{negative/multicast-endpoint-missing-protocol-and-source.json → positive/multicast-asm-unprotected.json} +10 -5
- package/test-vectors/catalog/positive/multicast-auth-asm-sender.json +78 -0
- package/test-vectors/catalog/positive/multicast-auth-rotation.json +39 -38
- package/test-vectors/catalog/positive/multicast-draft01-4-1-example.json +81 -0
- package/test-vectors/catalog/positive/multicast-draft01-7-2-6-example.json +70 -0
- package/test-vectors/catalog/positive/presentation-anchor-negative.json +27 -0
- package/test-vectors/catalog/section-codes.json +31 -1
- package/test-vectors/catalog-multicast-auth-v1.json +38 -20
- package/test-vectors/catalog-validation.json +101 -5
- package/test-vectors/catalog-validator-public-api.mjs +14 -9
- package/test-vectors/generate-bc-provenance-v2.mjs +252 -0
- package/dist/fec-codec.d.ts +0 -32
- package/dist/fec-codec.d.ts.map +0 -1
- package/dist/fec-codec.js +0 -47
- package/dist/fec-codec.js.map +0 -7
- package/dist/manifest-auth-plan.d.ts +0 -30
- package/dist/manifest-auth-plan.d.ts.map +0 -1
- package/dist/manifest-auth-plan.js +0 -1266
- package/dist/manifest-auth-plan.js.map +0 -7
- package/dist/source-auth.d.ts +0 -2
- package/dist/source-auth.d.ts.map +0 -1
- package/dist/source-auth.js +0 -1209
- package/dist/source-auth.js.map +0 -7
- package/src/fec-codec.ts +0 -61
- package/src/manifest-auth-plan.ts +0 -107
- package/src/source-auth.ts +0 -1
- package/test-vectors/generate-source-auth-fixture.mjs +0 -114
- package/test-vectors/source-auth-v1.json +0 -61
|
@@ -22,10 +22,19 @@ export type IsoRepairPlacement<T> = {
|
|
|
22
22
|
readonly block: IsoBlockRange;
|
|
23
23
|
readonly placed: readonly IsoPlacedSource<T>[];
|
|
24
24
|
};
|
|
25
|
+
/**
|
|
26
|
+
* With `deferIncompleteGaps`: the SS_IDs in front of `block` whose every
|
|
27
|
+
* repair was lost and some source too, kept as a pending hole instead of
|
|
28
|
+
* a span (see `closeHolesWithin`). `lostSsId` is the highest missing one.
|
|
29
|
+
*/
|
|
30
|
+
readonly hole?: {
|
|
31
|
+
readonly block: IsoBlockRange;
|
|
32
|
+
readonly lostSsId: number;
|
|
33
|
+
};
|
|
25
34
|
}
|
|
26
35
|
/** Not a block this stream can use; the repair symbol is dropped. */
|
|
27
36
|
| {
|
|
28
|
-
readonly status: 'conflict' | 'overlap' | 'stale';
|
|
37
|
+
readonly status: 'conflict' | 'overlap' | 'stale' | 'ahead';
|
|
29
38
|
readonly reason: string;
|
|
30
39
|
};
|
|
31
40
|
/**
|
|
@@ -43,6 +52,13 @@ export type IsoRepairPlacement<T> = {
|
|
|
43
52
|
*/
|
|
44
53
|
export declare class IsoBlockLocator<T> {
|
|
45
54
|
#private;
|
|
55
|
+
/**
|
|
56
|
+
* Keep a gap that is missing a source as a pending hole rather than a span,
|
|
57
|
+
* so a repair FETCHed for it (draft-ramadan-moq-fec §7.5) can still state
|
|
58
|
+
* its blocks. Set only while a range repair scheduler is wired; its owner
|
|
59
|
+
* must close every hole it is told about (`closeHolesWithin`).
|
|
60
|
+
*/
|
|
61
|
+
deferIncompleteGaps: boolean;
|
|
46
62
|
/**
|
|
47
63
|
* @param kMax the catalog maximum K (`sourceSymbols`), the bound on SSB_length.
|
|
48
64
|
* @param retentionBlocks how many blocks behind the newest position the
|
|
@@ -79,6 +95,10 @@ export declare class IsoBlockLocator<T> {
|
|
|
79
95
|
block: IsoBlockRange;
|
|
80
96
|
esi: number;
|
|
81
97
|
} | null;
|
|
98
|
+
/** Number of pending holes. */
|
|
99
|
+
get holeCount(): number;
|
|
100
|
+
/** The stated block (never a span) ending exactly at `end`. */
|
|
101
|
+
blockEndingAt(end: number): IsoBlockRange | undefined;
|
|
82
102
|
/** The known block or span starting exactly at `start`. */
|
|
83
103
|
blockAt(start: number): IsoBlockRange | undefined;
|
|
84
104
|
/** Known blocks and spans overlapping the SS_IDs strictly between `a` and `b`. */
|
|
@@ -103,8 +123,26 @@ export declare class IsoBlockLocator<T> {
|
|
|
103
123
|
* known block (a different length, or an overlap with another block or a
|
|
104
124
|
* span) fails closed: the repair symbol is dropped and no block changes.
|
|
105
125
|
* A newly stated block retires behind its SS_Start (see the class note).
|
|
126
|
+
* A block so far past `newest` that stating it would retire the position
|
|
127
|
+
* `newest` is refused as `ahead`. When `newest` is a placed block's SS_Start
|
|
128
|
+
* this is slightly conservative (retirement measures that block from its
|
|
129
|
+
* last SS_ID), dropping up to one block-length of repairs past the horizon
|
|
130
|
+
* until a source moves `newest`. Placing it would turn everything
|
|
131
|
+
* between into a repair-less span and leave every real repair behind it
|
|
132
|
+
* `stale`. Sources move `newest` (`hold`, `observe`), so after a real outage
|
|
133
|
+
* the first source back brings the next repair inside the horizon; until one
|
|
134
|
+
* arrives, a stream's repairs alone cannot pass it.
|
|
106
135
|
*/
|
|
107
136
|
placeRepair(start: number, length: number): IsoRepairPlacement<T>;
|
|
137
|
+
/**
|
|
138
|
+
* Turn every pending hole inside `[start, start + length)` into a
|
|
139
|
+
* repair-less span, claiming its held sources: its range FETCH ended, so
|
|
140
|
+
* nothing more will state its blocks. Returns the spans, in SS_ID order.
|
|
141
|
+
*/
|
|
142
|
+
closeHolesWithin(start: number, length: number): {
|
|
143
|
+
block: IsoBlockRange;
|
|
144
|
+
placed: IsoPlacedSource<T>[];
|
|
145
|
+
}[];
|
|
108
146
|
/**
|
|
109
147
|
* Retire every block and span whose last SS_ID, and every held source,
|
|
110
148
|
* lies more than `retentionBlocks` blocks behind `position`, with the shared
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"iso-block-locator.d.ts","sourceRoot":"","sources":["../src/iso-block-locator.ts"],"names":[],"mappings":"AA6BA,4EAA4E;AAC5E,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,6EAA6E;IAC7E,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;CACvB;AAED,kEAAkE;AAClE,MAAM,WAAW,eAAe,CAAC,CAAC;IAChC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,GAAG,EAAE,M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E,aAAa,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;IAUlE,+BAA+B;IAC/B,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED,+DAA+D;IAC/D,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS;IAIrD,2DAA2D;IAC3D,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS;IAIjD,kFAAkF;IAClF,aAAa,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,aAAa,EAAE;IAWpD;;;OAGG;IACH,aAAa,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO;IAW5C;;;;OAIG;IACH,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,GAAG,OAAO;IAYvC,uCAAuC;IACvC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAI7B;;;;;;;;;;;;;;;;OAgBG;IACH,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,kBAAkB,CAAC,CAAC,CAAC;IAoFjE;;;;OAIG;IACH,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG;QAAE,KAAK,EAAE,aAAa,CAAC;QAAC,MAAM,EAAE,eAAe,CAAC,CAAC,CAAC,EAAE,CAAA;KAAE,EAAE;IAuBzG;;;;;OAKG;IACH,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE;IAuBxC,0DAA0D;IAC1D,KAAK,IAAI,IAAI;CAkBd"}
|
|
@@ -53,16 +53,6 @@ var ALL_ROLES = Object.freeze(["video", "audio"]);
|
|
|
53
53
|
|
|
54
54
|
// src/iso-block-locator.ts
|
|
55
55
|
var IsoBlockLocator = class _IsoBlockLocator {
|
|
56
|
-
/** Known blocks and spans, in serial order of their start. */
|
|
57
|
-
#blocks = [];
|
|
58
|
-
/** Held first-arrival sources whose block no repair has stated yet. */
|
|
59
|
-
#held = /* @__PURE__ */ new Map();
|
|
60
|
-
/** End of contiguous coverage: the SS_ID the next unknown block starts at. */
|
|
61
|
-
#coverageEnd;
|
|
62
|
-
#kMax;
|
|
63
|
-
#retentionBlocks;
|
|
64
|
-
#heldEvicted = 0;
|
|
65
|
-
#newest;
|
|
66
56
|
/**
|
|
67
57
|
* @param kMax the catalog maximum K (`sourceSymbols`), the bound on SSB_length.
|
|
68
58
|
* @param retentionBlocks how many blocks behind the newest position the
|
|
@@ -70,12 +60,35 @@ var IsoBlockLocator = class _IsoBlockLocator {
|
|
|
70
60
|
* no locator exists without retention.
|
|
71
61
|
*/
|
|
72
62
|
constructor(kMax, retentionBlocks) {
|
|
63
|
+
/** Known blocks and spans, in serial order of their start. */
|
|
64
|
+
this.#blocks = [];
|
|
65
|
+
/** Held first-arrival sources whose block no repair has stated yet. */
|
|
66
|
+
this.#held = /* @__PURE__ */ new Map();
|
|
67
|
+
this.#heldEvicted = 0;
|
|
68
|
+
/** Pending holes (see `deferIncompleteGaps`): unstated, sources still held. */
|
|
69
|
+
this.#holes = [];
|
|
70
|
+
/**
|
|
71
|
+
* Keep a gap that is missing a source as a pending hole rather than a span,
|
|
72
|
+
* so a repair FETCHed for it (draft-ramadan-moq-fec §7.5) can still state
|
|
73
|
+
* its blocks. Set only while a range repair scheduler is wired; its owner
|
|
74
|
+
* must close every hole it is told about (`closeHolesWithin`).
|
|
75
|
+
*/
|
|
76
|
+
this.deferIncompleteGaps = false;
|
|
73
77
|
if (!Number.isSafeInteger(kMax) || kMax <= 0) {
|
|
74
78
|
throw new Error(`[IsoBlockLocator] maximum K must be a positive integer (got ${kMax})`);
|
|
75
79
|
}
|
|
76
80
|
this.#kMax = kMax;
|
|
77
81
|
this.#retentionBlocks = _IsoBlockLocator.#checkedRetention(retentionBlocks);
|
|
78
82
|
}
|
|
83
|
+
#blocks;
|
|
84
|
+
#held;
|
|
85
|
+
/** End of contiguous coverage: the SS_ID the next unknown block starts at. */
|
|
86
|
+
#coverageEnd;
|
|
87
|
+
#kMax;
|
|
88
|
+
#retentionBlocks;
|
|
89
|
+
#heldEvicted;
|
|
90
|
+
#newest;
|
|
91
|
+
#holes;
|
|
79
92
|
static #checkedRetention(retentionBlocks) {
|
|
80
93
|
if (!Number.isSafeInteger(retentionBlocks) || retentionBlocks <= 0) {
|
|
81
94
|
throw new Error(
|
|
@@ -138,6 +151,14 @@ var IsoBlockLocator = class _IsoBlockLocator {
|
|
|
138
151
|
}
|
|
139
152
|
return null;
|
|
140
153
|
}
|
|
154
|
+
/** Number of pending holes. */
|
|
155
|
+
get holeCount() {
|
|
156
|
+
return this.#holes.length;
|
|
157
|
+
}
|
|
158
|
+
/** The stated block (never a span) ending exactly at `end`. */
|
|
159
|
+
blockEndingAt(end) {
|
|
160
|
+
return this.#blocks.find((block) => !block.span && isoBlockEnd(block.start, block.length) === end);
|
|
161
|
+
}
|
|
141
162
|
/** The known block or span starting exactly at `start`. */
|
|
142
163
|
blockAt(start) {
|
|
143
164
|
return this.#blocks.find((block) => block.start === start);
|
|
@@ -160,6 +181,9 @@ var IsoBlockLocator = class _IsoBlockLocator {
|
|
|
160
181
|
coversBetween(a, b) {
|
|
161
182
|
if (this.#coverageEnd === void 0) return false;
|
|
162
183
|
if (!serial32Precedes(a, b) || serial32Distance(a, b) <= 1) return true;
|
|
184
|
+
const first = a + 1 >>> 0;
|
|
185
|
+
const count = serial32Distance(a, b) - 1;
|
|
186
|
+
if (this.#holes.some((hole) => isoRangesOverlap(first, count, hole.start, hole.length))) return false;
|
|
163
187
|
return serial32Precedes(b - 1 >>> 0, this.#coverageEnd);
|
|
164
188
|
}
|
|
165
189
|
/**
|
|
@@ -189,6 +213,15 @@ var IsoBlockLocator = class _IsoBlockLocator {
|
|
|
189
213
|
* known block (a different length, or an overlap with another block or a
|
|
190
214
|
* span) fails closed: the repair symbol is dropped and no block changes.
|
|
191
215
|
* A newly stated block retires behind its SS_Start (see the class note).
|
|
216
|
+
* A block so far past `newest` that stating it would retire the position
|
|
217
|
+
* `newest` is refused as `ahead`. When `newest` is a placed block's SS_Start
|
|
218
|
+
* this is slightly conservative (retirement measures that block from its
|
|
219
|
+
* last SS_ID), dropping up to one block-length of repairs past the horizon
|
|
220
|
+
* until a source moves `newest`. Placing it would turn everything
|
|
221
|
+
* between into a repair-less span and leave every real repair behind it
|
|
222
|
+
* `stale`. Sources move `newest` (`hold`, `observe`), so after a real outage
|
|
223
|
+
* the first source back brings the next repair inside the horizon; until one
|
|
224
|
+
* arrives, a stream's repairs alone cannot pass it.
|
|
192
225
|
*/
|
|
193
226
|
placeRepair(start, length) {
|
|
194
227
|
if (!Number.isSafeInteger(length) || length <= 0 || length > this.#kMax) {
|
|
@@ -207,6 +240,22 @@ var IsoBlockLocator = class _IsoBlockLocator {
|
|
|
207
240
|
}
|
|
208
241
|
return { status: "placed", block: known, placed: [] };
|
|
209
242
|
}
|
|
243
|
+
const pending = this.#holes.find((h) => isoBlockContains(h.start, h.length, start));
|
|
244
|
+
if (pending !== void 0) {
|
|
245
|
+
if (!isoBlockContains(pending.start, pending.length, serial32Add(start, length - 1))) {
|
|
246
|
+
return { status: "overlap", reason: `repair block ${start}+${length} runs past pending hole ${pending.start}+${pending.length}` };
|
|
247
|
+
}
|
|
248
|
+
this.#holes.splice(this.#holes.indexOf(pending), 1);
|
|
249
|
+
const before = serial32Distance(pending.start, start);
|
|
250
|
+
const afterStart = isoBlockEnd(start, length);
|
|
251
|
+
const after = pending.length - before - length;
|
|
252
|
+
if (before > 0) this.#holes.push({ start: pending.start, length: before, span: false });
|
|
253
|
+
if (after > 0) this.#holes.push({ start: afterStart, length: after, span: false });
|
|
254
|
+
const block2 = { start, length, span: false };
|
|
255
|
+
const placed2 = this.#claim(block2);
|
|
256
|
+
this.#blocks.push(block2);
|
|
257
|
+
return { status: "placed", block: block2, placed: placed2 };
|
|
258
|
+
}
|
|
210
259
|
for (const block2 of this.#blocks) {
|
|
211
260
|
if (isoBlockContains(block2.start, block2.length, start) || isoBlockContains(start, length, block2.start)) {
|
|
212
261
|
return {
|
|
@@ -215,7 +264,11 @@ var IsoBlockLocator = class _IsoBlockLocator {
|
|
|
215
264
|
};
|
|
216
265
|
}
|
|
217
266
|
}
|
|
267
|
+
if (this.#newest !== void 0 && isoBlocksBehindLowerBound(this.#newest, start, this.#kMax) > this.#retentionBlocks) {
|
|
268
|
+
return { status: "ahead", reason: `repair block ${start}+${length} is past the retention horizon ahead of ${this.#newest}` };
|
|
269
|
+
}
|
|
218
270
|
let span;
|
|
271
|
+
let hole;
|
|
219
272
|
if (this.#coverageEnd === void 0) {
|
|
220
273
|
for (const ssId of this.#held.keys()) {
|
|
221
274
|
if (serial32Precedes(ssId, start)) this.#held.delete(ssId);
|
|
@@ -224,21 +277,51 @@ var IsoBlockLocator = class _IsoBlockLocator {
|
|
|
224
277
|
} else if (serial32Precedes(start, this.#coverageEnd)) {
|
|
225
278
|
return { status: "stale", reason: `repair block ${start}+${length} precedes known coverage` };
|
|
226
279
|
} else if (start !== this.#coverageEnd) {
|
|
227
|
-
const
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
span:
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
280
|
+
const gap = { start: this.#coverageEnd, length: serial32Distance(this.#coverageEnd, start) };
|
|
281
|
+
const lostSsId = this.deferIncompleteGaps ? this.#highestMissing(gap.start, gap.length) : void 0;
|
|
282
|
+
if (lostSsId !== void 0) {
|
|
283
|
+
const holeBlock = { ...gap, span: false };
|
|
284
|
+
this.#holes.push(holeBlock);
|
|
285
|
+
hole = { block: holeBlock, lostSsId };
|
|
286
|
+
} else {
|
|
287
|
+
const spanBlock = { ...gap, span: true };
|
|
288
|
+
span = { block: spanBlock, placed: this.#claim(spanBlock) };
|
|
289
|
+
this.#blocks.push(spanBlock);
|
|
290
|
+
}
|
|
234
291
|
}
|
|
235
292
|
const block = { start, length, span: false };
|
|
236
293
|
const placed = this.#claim(block);
|
|
237
294
|
this.#blocks.push(block);
|
|
238
295
|
this.#coverageEnd = isoBlockEnd(start, length);
|
|
239
296
|
this.retireBehind(start);
|
|
297
|
+
if (hole !== void 0) return { status: "placed", block, placed, hole };
|
|
240
298
|
return span === void 0 ? { status: "placed", block, placed } : { status: "placed", block, placed, span };
|
|
241
299
|
}
|
|
300
|
+
/**
|
|
301
|
+
* Turn every pending hole inside `[start, start + length)` into a
|
|
302
|
+
* repair-less span, claiming its held sources: its range FETCH ended, so
|
|
303
|
+
* nothing more will state its blocks. Returns the spans, in SS_ID order.
|
|
304
|
+
*/
|
|
305
|
+
closeHolesWithin(start, length) {
|
|
306
|
+
const closed = [];
|
|
307
|
+
for (const hole of [...this.#holes]) {
|
|
308
|
+
if (!isoBlockContains(start, length, hole.start)) continue;
|
|
309
|
+
this.#holes.splice(this.#holes.indexOf(hole), 1);
|
|
310
|
+
const spanBlock = { start: hole.start, length: hole.length, span: true };
|
|
311
|
+
closed.push({ block: spanBlock, placed: this.#claim(spanBlock) });
|
|
312
|
+
this.#blocks.push(spanBlock);
|
|
313
|
+
}
|
|
314
|
+
return closed.sort((x, y) => serial32Distance(start, x.block.start) - serial32Distance(start, y.block.start));
|
|
315
|
+
}
|
|
316
|
+
/** The highest SS_ID in the range no source is held for, or undefined when all are. */
|
|
317
|
+
#highestMissing(start, length) {
|
|
318
|
+
const steps = Math.min(length, this.#held.size + 1);
|
|
319
|
+
for (let i = 1; i <= steps; i++) {
|
|
320
|
+
const ssId = serial32Add(start, length - i);
|
|
321
|
+
if (!this.#held.has(ssId)) return ssId;
|
|
322
|
+
}
|
|
323
|
+
return void 0;
|
|
324
|
+
}
|
|
242
325
|
/**
|
|
243
326
|
* Retire every block and span whose last SS_ID, and every held source,
|
|
244
327
|
* lies more than `retentionBlocks` blocks behind `position`, with the shared
|
|
@@ -257,6 +340,11 @@ var IsoBlockLocator = class _IsoBlockLocator {
|
|
|
257
340
|
this.#blocks.splice(i, 1);
|
|
258
341
|
}
|
|
259
342
|
}
|
|
343
|
+
for (let i = this.#holes.length - 1; i >= 0; i--) {
|
|
344
|
+
const hole = this.#holes[i];
|
|
345
|
+
const last = serial32Add(hole.start, hole.length - 1);
|
|
346
|
+
if (isoBlocksBehindLowerBound(last, position, this.#kMax) > horizon) this.#holes.splice(i, 1);
|
|
347
|
+
}
|
|
260
348
|
for (const ssId of [...this.#held.keys()]) {
|
|
261
349
|
if (isoBlocksBehindLowerBound(ssId, position, this.#kMax) > horizon) this.#held.delete(ssId);
|
|
262
350
|
}
|
|
@@ -265,6 +353,7 @@ var IsoBlockLocator = class _IsoBlockLocator {
|
|
|
265
353
|
/** Forget everything (publisher restart, track reset). */
|
|
266
354
|
reset() {
|
|
267
355
|
this.#blocks.length = 0;
|
|
356
|
+
this.#holes.length = 0;
|
|
268
357
|
this.#held.clear();
|
|
269
358
|
this.#coverageEnd = void 0;
|
|
270
359
|
this.#newest = void 0;
|
|
@@ -280,6 +369,9 @@ var IsoBlockLocator = class _IsoBlockLocator {
|
|
|
280
369
|
return placed;
|
|
281
370
|
}
|
|
282
371
|
};
|
|
372
|
+
function isoRangesOverlap(aStart, aLength, bStart, bLength) {
|
|
373
|
+
return serial32Distance(aStart, bStart) < aLength || serial32Distance(bStart, aStart) < bLength;
|
|
374
|
+
}
|
|
283
375
|
export {
|
|
284
376
|
IsoBlockLocator
|
|
285
377
|
};
|