@leofcoin/chain 1.7.74 → 1.7.76
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/exports/browser/chain.js
CHANGED
|
@@ -5303,6 +5303,7 @@ class ConnectionMonitor {
|
|
|
5303
5303
|
#maxReconnectAttempts = 10;
|
|
5304
5304
|
#reconnectDelay = 5000;
|
|
5305
5305
|
#healthCheckInterval = 10000;
|
|
5306
|
+
#version;
|
|
5306
5307
|
get isMonitoring() {
|
|
5307
5308
|
return this.#isMonitoring;
|
|
5308
5309
|
}
|
|
@@ -5310,12 +5311,13 @@ class ConnectionMonitor {
|
|
|
5310
5311
|
return Object.values(globalThis.peernet?.connections || {}).filter((peer) => peer.connected);
|
|
5311
5312
|
}
|
|
5312
5313
|
get compatiblePeers() {
|
|
5313
|
-
return this.connectedPeers.filter((peer) => peer.version === this
|
|
5314
|
+
return this.connectedPeers.filter((peer) => peer.version === this.#version);
|
|
5314
5315
|
}
|
|
5315
5316
|
constructor(version) {
|
|
5316
|
-
|
|
5317
|
+
console.log(`🔗 Connection Monitor initialized for version: ${this.#version}`);
|
|
5317
5318
|
}
|
|
5318
|
-
start() {
|
|
5319
|
+
start(version) {
|
|
5320
|
+
this.#version = version;
|
|
5319
5321
|
if (this.#isMonitoring)
|
|
5320
5322
|
return;
|
|
5321
5323
|
this.#isMonitoring = true;
|
|
@@ -5503,7 +5505,7 @@ class Chain extends VersionControl {
|
|
|
5503
5505
|
// this.node = await new Node()
|
|
5504
5506
|
this.#participants = [];
|
|
5505
5507
|
this.#participating = false;
|
|
5506
|
-
this.#connectionMonitor = new ConnectionMonitor(
|
|
5508
|
+
this.#connectionMonitor = new ConnectionMonitor();
|
|
5507
5509
|
const initialized = await globalThis.contractStore.has(addresses.contractFactory);
|
|
5508
5510
|
if (!initialized)
|
|
5509
5511
|
await this.#setup();
|
|
@@ -5512,7 +5514,7 @@ class Chain extends VersionControl {
|
|
|
5512
5514
|
// todo some functions rely on state
|
|
5513
5515
|
await super.init();
|
|
5514
5516
|
// Start connection monitoring
|
|
5515
|
-
this.#connectionMonitor.start();
|
|
5517
|
+
this.#connectionMonitor.start(this.version);
|
|
5516
5518
|
await globalThis.peernet.addRequestHandler('bw-request-message', () => {
|
|
5517
5519
|
const bw = globalThis.peernet.client?.bw || { up: 0, down: 0 };
|
|
5518
5520
|
return new BWMessage(bw);
|
package/exports/chain.js
CHANGED
|
@@ -1449,6 +1449,7 @@ class ConnectionMonitor {
|
|
|
1449
1449
|
#maxReconnectAttempts = 10;
|
|
1450
1450
|
#reconnectDelay = 5000;
|
|
1451
1451
|
#healthCheckInterval = 10000;
|
|
1452
|
+
#version;
|
|
1452
1453
|
get isMonitoring() {
|
|
1453
1454
|
return this.#isMonitoring;
|
|
1454
1455
|
}
|
|
@@ -1456,12 +1457,13 @@ class ConnectionMonitor {
|
|
|
1456
1457
|
return Object.values(globalThis.peernet?.connections || {}).filter((peer) => peer.connected);
|
|
1457
1458
|
}
|
|
1458
1459
|
get compatiblePeers() {
|
|
1459
|
-
return this.connectedPeers.filter((peer) => peer.version === this
|
|
1460
|
+
return this.connectedPeers.filter((peer) => peer.version === this.#version);
|
|
1460
1461
|
}
|
|
1461
1462
|
constructor(version) {
|
|
1462
|
-
|
|
1463
|
+
console.log(`🔗 Connection Monitor initialized for version: ${this.#version}`);
|
|
1463
1464
|
}
|
|
1464
|
-
start() {
|
|
1465
|
+
start(version) {
|
|
1466
|
+
this.#version = version;
|
|
1465
1467
|
if (this.#isMonitoring)
|
|
1466
1468
|
return;
|
|
1467
1469
|
this.#isMonitoring = true;
|
|
@@ -1649,7 +1651,7 @@ class Chain extends VersionControl {
|
|
|
1649
1651
|
// this.node = await new Node()
|
|
1650
1652
|
this.#participants = [];
|
|
1651
1653
|
this.#participating = false;
|
|
1652
|
-
this.#connectionMonitor = new ConnectionMonitor(
|
|
1654
|
+
this.#connectionMonitor = new ConnectionMonitor();
|
|
1653
1655
|
const initialized = await globalThis.contractStore.has(addresses.contractFactory);
|
|
1654
1656
|
if (!initialized)
|
|
1655
1657
|
await this.#setup();
|
|
@@ -1658,7 +1660,7 @@ class Chain extends VersionControl {
|
|
|
1658
1660
|
// todo some functions rely on state
|
|
1659
1661
|
await super.init();
|
|
1660
1662
|
// Start connection monitoring
|
|
1661
|
-
this.#connectionMonitor.start();
|
|
1663
|
+
this.#connectionMonitor.start(this.version);
|
|
1662
1664
|
await globalThis.peernet.addRequestHandler('bw-request-message', () => {
|
|
1663
1665
|
const bw = globalThis.peernet.client?.bw || { up: 0, down: 0 };
|
|
1664
1666
|
return new BWMessage(bw);
|
|
@@ -3,12 +3,11 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export default class ConnectionMonitor {
|
|
5
5
|
#private;
|
|
6
|
-
private version;
|
|
7
6
|
get isMonitoring(): boolean;
|
|
8
7
|
get connectedPeers(): import("@netpeer/swarm/peer").default[];
|
|
9
8
|
get compatiblePeers(): import("@netpeer/swarm/peer").default[];
|
|
10
9
|
constructor(version: string);
|
|
11
|
-
start(): void;
|
|
10
|
+
start(version: any): void;
|
|
12
11
|
stop(): void;
|
|
13
12
|
waitForPeers(timeoutMs?: number): Promise<boolean>;
|
|
14
13
|
}
|