wire-mesh-core 4.2.3 → 4.2.4

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.
@@ -30,9 +30,10 @@ var CoordinatorElection = class {
30
30
  return this.incumbent !== void 0 && compareDeviceIds(this.incumbent.coordinator, this.ownDevice) === 0;
31
31
  }
32
32
  /**
33
- * Claims the role for this side's own device at a term above every term seen so far (lastTerm + 1, so a first-ever claim is term 0), and returns the frame to gossip. Throws a RangeError when that term is not one peers accept (isSupersedableTerm), which only happens when the incumbent already sits at the highest term the election accepts. Claiming over a claim this side already holds is a deliberate takeover: it raises the term, which is exactly what a peer recovering the role after losing track of the mesh should do, and what a routine refresh should not (announceCurrent exists for that).
33
+ * Claims the role for this side's own device at a term above every term seen so far (lastTerm + 1, so a first-ever claim is term 0), and returns the frame to gossip. Throws a RangeError when that term is not one peers accept (isSupersedableTerm), which only happens when the incumbent already sits at the highest term the election accepts, and when capacityHint is not a non-negative safe integer: the wire carries it as an unsigned integer that a peer reading it as a number must hold exactly, so any other value would be dropped as malformed by every peer. Claiming over a claim this side already holds is a deliberate takeover: it raises the term, which is exactly what a peer recovering the role after losing track of the mesh should do, and what a routine refresh should not (announceCurrent exists for that).
34
34
  */
35
35
  claim(capacityHint) {
36
+ if (capacityHint !== void 0 && !(Number.isSafeInteger(capacityHint) && capacityHint >= 0)) throw new RangeError(`the capacity hint ${String(capacityHint)} is not a non-negative safe integer`);
36
37
  const lastTerm = this.incumbent?.term ?? -1;
37
38
  const term = lastTerm + 1;
38
39
  if (!isSupersedableTerm(term)) throw new RangeError(`the incumbent's term ${String(lastTerm)} leaves no term a claim can be raised to`);
@@ -33,7 +33,7 @@ export declare class CoordinatorElection {
33
33
  /** Whether this side's own device is the incumbent. */
34
34
  isSelf(): boolean;
35
35
  /**
36
- * Claims the role for this side's own device at a term above every term seen so far (lastTerm + 1, so a first-ever claim is term 0), and returns the frame to gossip. Throws a RangeError when that term is not one peers accept (isSupersedableTerm), which only happens when the incumbent already sits at the highest term the election accepts. Claiming over a claim this side already holds is a deliberate takeover: it raises the term, which is exactly what a peer recovering the role after losing track of the mesh should do, and what a routine refresh should not (announceCurrent exists for that).
36
+ * Claims the role for this side's own device at a term above every term seen so far (lastTerm + 1, so a first-ever claim is term 0), and returns the frame to gossip. Throws a RangeError when that term is not one peers accept (isSupersedableTerm), which only happens when the incumbent already sits at the highest term the election accepts, and when capacityHint is not a non-negative safe integer: the wire carries it as an unsigned integer that a peer reading it as a number must hold exactly, so any other value would be dropped as malformed by every peer. Claiming over a claim this side already holds is a deliberate takeover: it raises the term, which is exactly what a peer recovering the role after losing track of the mesh should do, and what a routine refresh should not (announceCurrent exists for that).
37
37
  */
38
38
  claim(capacityHint?: number): CoordinatorFrame;
39
39
  /**
@@ -33,7 +33,7 @@ export declare class CoordinatorElection {
33
33
  /** Whether this side's own device is the incumbent. */
34
34
  isSelf(): boolean;
35
35
  /**
36
- * Claims the role for this side's own device at a term above every term seen so far (lastTerm + 1, so a first-ever claim is term 0), and returns the frame to gossip. Throws a RangeError when that term is not one peers accept (isSupersedableTerm), which only happens when the incumbent already sits at the highest term the election accepts. Claiming over a claim this side already holds is a deliberate takeover: it raises the term, which is exactly what a peer recovering the role after losing track of the mesh should do, and what a routine refresh should not (announceCurrent exists for that).
36
+ * Claims the role for this side's own device at a term above every term seen so far (lastTerm + 1, so a first-ever claim is term 0), and returns the frame to gossip. Throws a RangeError when that term is not one peers accept (isSupersedableTerm), which only happens when the incumbent already sits at the highest term the election accepts, and when capacityHint is not a non-negative safe integer: the wire carries it as an unsigned integer that a peer reading it as a number must hold exactly, so any other value would be dropped as malformed by every peer. Claiming over a claim this side already holds is a deliberate takeover: it raises the term, which is exactly what a peer recovering the role after losing track of the mesh should do, and what a routine refresh should not (announceCurrent exists for that).
37
37
  */
38
38
  claim(capacityHint?: number): CoordinatorFrame;
39
39
  /**
@@ -29,9 +29,10 @@ var CoordinatorElection = class {
29
29
  return this.incumbent !== void 0 && compareDeviceIds(this.incumbent.coordinator, this.ownDevice) === 0;
30
30
  }
31
31
  /**
32
- * Claims the role for this side's own device at a term above every term seen so far (lastTerm + 1, so a first-ever claim is term 0), and returns the frame to gossip. Throws a RangeError when that term is not one peers accept (isSupersedableTerm), which only happens when the incumbent already sits at the highest term the election accepts. Claiming over a claim this side already holds is a deliberate takeover: it raises the term, which is exactly what a peer recovering the role after losing track of the mesh should do, and what a routine refresh should not (announceCurrent exists for that).
32
+ * Claims the role for this side's own device at a term above every term seen so far (lastTerm + 1, so a first-ever claim is term 0), and returns the frame to gossip. Throws a RangeError when that term is not one peers accept (isSupersedableTerm), which only happens when the incumbent already sits at the highest term the election accepts, and when capacityHint is not a non-negative safe integer: the wire carries it as an unsigned integer that a peer reading it as a number must hold exactly, so any other value would be dropped as malformed by every peer. Claiming over a claim this side already holds is a deliberate takeover: it raises the term, which is exactly what a peer recovering the role after losing track of the mesh should do, and what a routine refresh should not (announceCurrent exists for that).
33
33
  */
34
34
  claim(capacityHint) {
35
+ if (capacityHint !== void 0 && !(Number.isSafeInteger(capacityHint) && capacityHint >= 0)) throw new RangeError(`the capacity hint ${String(capacityHint)} is not a non-negative safe integer`);
35
36
  const lastTerm = this.incumbent?.term ?? -1;
36
37
  const term = lastTerm + 1;
37
38
  if (!isSupersedableTerm(term)) throw new RangeError(`the incumbent's term ${String(lastTerm)} leaves no term a claim can be raised to`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wire-mesh-core",
3
- "version": "4.2.3",
3
+ "version": "4.2.4",
4
4
  "dependencies": {
5
5
  "cbor2": "2.3.0",
6
6
  "cddl.js": "2.0.0",