@blockcast/mmt-container 2.0.0 → 2.0.1-main.57647cd30645
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
|
@@ -11633,7 +11633,6 @@ var BlockcastMmt = (() => {
|
|
|
11633
11633
|
var BCPV2_LEAD_BOUND_MS = 5e3;
|
|
11634
11634
|
var REPLAY_WINDOW = 64n;
|
|
11635
11635
|
var BUCKET_DEPTH = 64;
|
|
11636
|
-
var BUCKET_RATE_PER_MS = 1;
|
|
11637
11636
|
var hex = (bytes) => Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");
|
|
11638
11637
|
function sameBytes(a, b) {
|
|
11639
11638
|
if (a.byteLength !== b.byteLength)
|
|
@@ -11663,6 +11662,10 @@ var BlockcastMmt = (() => {
|
|
|
11663
11662
|
__publicField(this, "verifySig");
|
|
11664
11663
|
__publicField(this, "accepted");
|
|
11665
11664
|
__publicField(this, "queueLimit");
|
|
11665
|
+
/** Octets a held datagram is charged beyond its payload: the IPv4 or IPv6 plus UDP headers (step 2). */
|
|
11666
|
+
__publicField(this, "headerOctets");
|
|
11667
|
+
/** Budget refill, tokens per ms: V / 1000 (step 1). */
|
|
11668
|
+
__publicField(this, "bucketRatePerMs");
|
|
11666
11669
|
__publicField(this, "current", null);
|
|
11667
11670
|
__publicField(this, "previous", null);
|
|
11668
11671
|
__publicField(this, "graceStart", {});
|
|
@@ -11707,6 +11710,8 @@ var BlockcastMmt = (() => {
|
|
|
11707
11710
|
multicast: this.maxAuthDelayMs * bandwidth / 8e3,
|
|
11708
11711
|
unicast: (this.maxAuthDelayMs + this.widenMs) * bandwidth / 8e3
|
|
11709
11712
|
};
|
|
11713
|
+
this.headerOctets = parseBcProvenanceV2Address(cfg.endpoint.groupAddress).byteLength === 16 ? 48 : 28;
|
|
11714
|
+
this.bucketRatePerMs = Math.max(1e3, 1.25 * bandwidth / (8 * 512 * 37)) / 1e3;
|
|
11710
11715
|
const t = this.now();
|
|
11711
11716
|
this.buckets = {
|
|
11712
11717
|
multicast: { tokens: BUCKET_DEPTH, last: t, dropped: 0 },
|
|
@@ -11806,7 +11811,7 @@ var BlockcastMmt = (() => {
|
|
|
11806
11811
|
arrival: now,
|
|
11807
11812
|
sent,
|
|
11808
11813
|
digest: hex(sha2562(bytes)),
|
|
11809
|
-
pairs: record.digests.map((d, i) => ({ digest: hex(d), seq: record.firstSeq + BigInt(i), admitted: false })),
|
|
11814
|
+
pairs: record.digests.map((d, i) => ({ digest: hex(d), epoch, seq: record.firstSeq + BigInt(i), admitted: false })),
|
|
11810
11815
|
awaitingMulticast: path === "mirror"
|
|
11811
11816
|
};
|
|
11812
11817
|
this.verified.set(id, entry);
|
|
@@ -11873,12 +11878,12 @@ var BlockcastMmt = (() => {
|
|
|
11873
11878
|
digest(datagram) {
|
|
11874
11879
|
return hex(bcProvenanceV2DatagramDigest(this.cfg.endpoint, datagram));
|
|
11875
11880
|
}
|
|
11876
|
-
/** Consume the
|
|
11881
|
+
/** Consume the pending entry for `digest` lowest in (epoch, sequence) order, admitting it. */
|
|
11877
11882
|
consumePending(digest, now) {
|
|
11878
11883
|
const list = this.pending.get(digest);
|
|
11879
11884
|
if (!list?.length)
|
|
11880
11885
|
return false;
|
|
11881
|
-
list.sort((a, b) => a.pair.seq < b.pair.seq ? -1 : a.pair.seq > b.pair.seq ? 1 : 0);
|
|
11886
|
+
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));
|
|
11882
11887
|
const hit = list.shift();
|
|
11883
11888
|
if (list.length === 0)
|
|
11884
11889
|
this.pending.delete(digest);
|
|
@@ -11887,14 +11892,18 @@ var BlockcastMmt = (() => {
|
|
|
11887
11892
|
this.admittedUntil.set(digest, now + this.maxAuthDelayMs + this.leadMs);
|
|
11888
11893
|
return true;
|
|
11889
11894
|
}
|
|
11895
|
+
/** A held datagram's charge against its queue: payload plus IP and UDP headers. */
|
|
11896
|
+
charge(held) {
|
|
11897
|
+
return held.datagram.byteLength + this.headerOctets;
|
|
11898
|
+
}
|
|
11890
11899
|
enqueue(held, path, now) {
|
|
11891
|
-
if (this.holdBytes[path] + held
|
|
11900
|
+
if (this.holdBytes[path] + this.charge(held) > this.queueLimit[path]) {
|
|
11892
11901
|
return { verdict: "overflow", admitted: [] };
|
|
11893
11902
|
}
|
|
11894
11903
|
held.expiry = now + this.maxAuthDelayMs + (path === "unicast" ? this.widenMs : 0);
|
|
11895
11904
|
held.order = this.order++;
|
|
11896
11905
|
this.hold[path].push(held);
|
|
11897
|
-
this.holdBytes[path] += held
|
|
11906
|
+
this.holdBytes[path] += this.charge(held);
|
|
11898
11907
|
return { verdict: "held", admitted: [] };
|
|
11899
11908
|
}
|
|
11900
11909
|
/** Remove and return the oldest held datagram with `digest`, across both queues. */
|
|
@@ -11909,7 +11918,7 @@ var BlockcastMmt = (() => {
|
|
|
11909
11918
|
if (!best)
|
|
11910
11919
|
return void 0;
|
|
11911
11920
|
const [held] = this.hold[best.path].splice(best.index, 1);
|
|
11912
|
-
this.holdBytes[best.path] -= held
|
|
11921
|
+
this.holdBytes[best.path] -= this.charge(held);
|
|
11913
11922
|
return held.datagram;
|
|
11914
11923
|
}
|
|
11915
11924
|
dropAdmittedHeld() {
|
|
@@ -11917,7 +11926,7 @@ var BlockcastMmt = (() => {
|
|
|
11917
11926
|
this.hold[path] = this.hold[path].filter((h) => {
|
|
11918
11927
|
const keep = h.digest === void 0 || !this.admittedUntil.has(h.digest);
|
|
11919
11928
|
if (!keep)
|
|
11920
|
-
this.holdBytes[path] -= h
|
|
11929
|
+
this.holdBytes[path] -= this.charge(h);
|
|
11921
11930
|
return keep;
|
|
11922
11931
|
});
|
|
11923
11932
|
}
|
|
@@ -12002,7 +12011,7 @@ var BlockcastMmt = (() => {
|
|
|
12002
12011
|
}
|
|
12003
12012
|
take(path, now) {
|
|
12004
12013
|
const b = this.buckets[path];
|
|
12005
|
-
b.tokens = Math.min(BUCKET_DEPTH, b.tokens + (now - b.last) *
|
|
12014
|
+
b.tokens = Math.min(BUCKET_DEPTH, b.tokens + (now - b.last) * this.bucketRatePerMs);
|
|
12006
12015
|
b.last = now;
|
|
12007
12016
|
if (b.tokens < 1) {
|
|
12008
12017
|
b.dropped++;
|
|
@@ -12016,7 +12025,7 @@ var BlockcastMmt = (() => {
|
|
|
12016
12025
|
this.hold[path] = this.hold[path].filter((h) => {
|
|
12017
12026
|
if (h.expiry > now)
|
|
12018
12027
|
return true;
|
|
12019
|
-
this.holdBytes[path] -= h
|
|
12028
|
+
this.holdBytes[path] -= this.charge(h);
|
|
12020
12029
|
this.expired[path]++;
|
|
12021
12030
|
return false;
|
|
12022
12031
|
});
|