@blockcast/mmt-container 2.0.0 → 2.0.1-main.f22764ad18fb
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 +1 -1
- package/dist/browser-runtime.js +45 -12
- package/dist/browser-runtime.js.map +2 -2
- package/dist/delivery-catalog.js +3 -0
- package/dist/delivery-catalog.js.map +2 -2
- package/dist/mmtp-container-parser.no-modules.js +19 -10
- package/dist/mmtp-container-parser.no-modules.js.map +2 -2
- package/dist/multicast-manager.js +45 -12
- package/dist/multicast-manager.js.map +2 -2
- package/dist/multicast-transport.d.ts +8 -1
- package/dist/multicast-transport.d.ts.map +1 -1
- package/dist/multicast-transport.js +93 -2
- package/dist/multicast-transport.js.map +4 -4
- package/dist/no-modules.js +19 -10
- package/dist/no-modules.js.map +2 -2
- package/package.json +5 -5
- package/src/multicast-transport.ts +43 -4
package/dist/no-modules.js
CHANGED
|
@@ -11454,7 +11454,6 @@ _RistrettoPoint.Fn = /* @__PURE__ */ (() => Fn)();
|
|
|
11454
11454
|
var BCPV2_LEAD_BOUND_MS = 5e3;
|
|
11455
11455
|
var REPLAY_WINDOW = 64n;
|
|
11456
11456
|
var BUCKET_DEPTH = 64;
|
|
11457
|
-
var BUCKET_RATE_PER_MS = 1;
|
|
11458
11457
|
var hex = (bytes) => Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");
|
|
11459
11458
|
function sameBytes(a, b) {
|
|
11460
11459
|
if (a.byteLength !== b.byteLength)
|
|
@@ -11483,6 +11482,10 @@ var BcProvenanceV2Receiver = class {
|
|
|
11483
11482
|
verifySig;
|
|
11484
11483
|
accepted;
|
|
11485
11484
|
queueLimit;
|
|
11485
|
+
/** Octets a held datagram is charged beyond its payload: the IPv4 or IPv6 plus UDP headers (step 2). */
|
|
11486
|
+
headerOctets;
|
|
11487
|
+
/** Budget refill, tokens per ms: V / 1000 (step 1). */
|
|
11488
|
+
bucketRatePerMs;
|
|
11486
11489
|
current = null;
|
|
11487
11490
|
previous = null;
|
|
11488
11491
|
graceStart = {};
|
|
@@ -11528,6 +11531,8 @@ var BcProvenanceV2Receiver = class {
|
|
|
11528
11531
|
multicast: this.maxAuthDelayMs * bandwidth / 8e3,
|
|
11529
11532
|
unicast: (this.maxAuthDelayMs + this.widenMs) * bandwidth / 8e3
|
|
11530
11533
|
};
|
|
11534
|
+
this.headerOctets = parseBcProvenanceV2Address(cfg.endpoint.groupAddress).byteLength === 16 ? 48 : 28;
|
|
11535
|
+
this.bucketRatePerMs = Math.max(1e3, 1.25 * bandwidth / (8 * 512 * 37)) / 1e3;
|
|
11531
11536
|
const t = this.now();
|
|
11532
11537
|
this.buckets = {
|
|
11533
11538
|
multicast: { tokens: BUCKET_DEPTH, last: t, dropped: 0 },
|
|
@@ -11626,7 +11631,7 @@ var BcProvenanceV2Receiver = class {
|
|
|
11626
11631
|
arrival: now,
|
|
11627
11632
|
sent,
|
|
11628
11633
|
digest: hex(sha2562(bytes)),
|
|
11629
|
-
pairs: record.digests.map((d, i) => ({ digest: hex(d), seq: record.firstSeq + BigInt(i), admitted: false })),
|
|
11634
|
+
pairs: record.digests.map((d, i) => ({ digest: hex(d), epoch, seq: record.firstSeq + BigInt(i), admitted: false })),
|
|
11630
11635
|
awaitingMulticast: path === "mirror"
|
|
11631
11636
|
};
|
|
11632
11637
|
this.verified.set(id, entry);
|
|
@@ -11693,12 +11698,12 @@ var BcProvenanceV2Receiver = class {
|
|
|
11693
11698
|
digest(datagram) {
|
|
11694
11699
|
return hex(bcProvenanceV2DatagramDigest(this.cfg.endpoint, datagram));
|
|
11695
11700
|
}
|
|
11696
|
-
/** Consume the
|
|
11701
|
+
/** Consume the pending entry for `digest` lowest in (epoch, sequence) order, admitting it. */
|
|
11697
11702
|
consumePending(digest, now) {
|
|
11698
11703
|
const list = this.pending.get(digest);
|
|
11699
11704
|
if (!list?.length)
|
|
11700
11705
|
return false;
|
|
11701
|
-
list.sort((a, b) => a.pair.seq < b.pair.seq ? -1 : a.pair.seq > b.pair.seq ? 1 : 0);
|
|
11706
|
+
list.sort((a, b) => a.pair.epoch - b.pair.epoch || (a.pair.seq < b.pair.seq ? -1 : a.pair.seq > b.pair.seq ? 1 : 0));
|
|
11702
11707
|
const hit = list.shift();
|
|
11703
11708
|
if (list.length === 0)
|
|
11704
11709
|
this.pending.delete(digest);
|
|
@@ -11707,14 +11712,18 @@ var BcProvenanceV2Receiver = class {
|
|
|
11707
11712
|
this.admittedUntil.set(digest, now + this.maxAuthDelayMs + this.leadMs);
|
|
11708
11713
|
return true;
|
|
11709
11714
|
}
|
|
11715
|
+
/** A held datagram's charge against its queue: payload plus IP and UDP headers. */
|
|
11716
|
+
charge(held) {
|
|
11717
|
+
return held.datagram.byteLength + this.headerOctets;
|
|
11718
|
+
}
|
|
11710
11719
|
enqueue(held, path, now) {
|
|
11711
|
-
if (this.holdBytes[path] + held
|
|
11720
|
+
if (this.holdBytes[path] + this.charge(held) > this.queueLimit[path]) {
|
|
11712
11721
|
return { verdict: "overflow", admitted: [] };
|
|
11713
11722
|
}
|
|
11714
11723
|
held.expiry = now + this.maxAuthDelayMs + (path === "unicast" ? this.widenMs : 0);
|
|
11715
11724
|
held.order = this.order++;
|
|
11716
11725
|
this.hold[path].push(held);
|
|
11717
|
-
this.holdBytes[path] += held
|
|
11726
|
+
this.holdBytes[path] += this.charge(held);
|
|
11718
11727
|
return { verdict: "held", admitted: [] };
|
|
11719
11728
|
}
|
|
11720
11729
|
/** Remove and return the oldest held datagram with `digest`, across both queues. */
|
|
@@ -11729,7 +11738,7 @@ var BcProvenanceV2Receiver = class {
|
|
|
11729
11738
|
if (!best)
|
|
11730
11739
|
return void 0;
|
|
11731
11740
|
const [held] = this.hold[best.path].splice(best.index, 1);
|
|
11732
|
-
this.holdBytes[best.path] -= held
|
|
11741
|
+
this.holdBytes[best.path] -= this.charge(held);
|
|
11733
11742
|
return held.datagram;
|
|
11734
11743
|
}
|
|
11735
11744
|
dropAdmittedHeld() {
|
|
@@ -11737,7 +11746,7 @@ var BcProvenanceV2Receiver = class {
|
|
|
11737
11746
|
this.hold[path] = this.hold[path].filter((h) => {
|
|
11738
11747
|
const keep = h.digest === void 0 || !this.admittedUntil.has(h.digest);
|
|
11739
11748
|
if (!keep)
|
|
11740
|
-
this.holdBytes[path] -= h
|
|
11749
|
+
this.holdBytes[path] -= this.charge(h);
|
|
11741
11750
|
return keep;
|
|
11742
11751
|
});
|
|
11743
11752
|
}
|
|
@@ -11821,7 +11830,7 @@ var BcProvenanceV2Receiver = class {
|
|
|
11821
11830
|
}
|
|
11822
11831
|
take(path, now) {
|
|
11823
11832
|
const b = this.buckets[path];
|
|
11824
|
-
b.tokens = Math.min(BUCKET_DEPTH, b.tokens + (now - b.last) *
|
|
11833
|
+
b.tokens = Math.min(BUCKET_DEPTH, b.tokens + (now - b.last) * this.bucketRatePerMs);
|
|
11825
11834
|
b.last = now;
|
|
11826
11835
|
if (b.tokens < 1) {
|
|
11827
11836
|
b.dropped++;
|
|
@@ -11835,7 +11844,7 @@ var BcProvenanceV2Receiver = class {
|
|
|
11835
11844
|
this.hold[path] = this.hold[path].filter((h) => {
|
|
11836
11845
|
if (h.expiry > now)
|
|
11837
11846
|
return true;
|
|
11838
|
-
this.holdBytes[path] -= h
|
|
11847
|
+
this.holdBytes[path] -= this.charge(h);
|
|
11839
11848
|
this.expired[path]++;
|
|
11840
11849
|
return false;
|
|
11841
11850
|
});
|