@leofcoin/chain 1.7.92 → 1.7.93
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 +10 -14
- package/exports/chain.js +10 -14
- package/package.json +1 -1
package/exports/browser/chain.js
CHANGED
|
@@ -5312,7 +5312,6 @@ class VersionControl extends State {
|
|
|
5312
5312
|
class ConnectionMonitor {
|
|
5313
5313
|
#isMonitoring = false;
|
|
5314
5314
|
#checkInterval = null;
|
|
5315
|
-
#reconnectAttempts = 0;
|
|
5316
5315
|
#peerReconnectAttempts = {};
|
|
5317
5316
|
#maxReconnectAttempts = 10;
|
|
5318
5317
|
#reconnectDelay = 5000;
|
|
@@ -5366,10 +5365,6 @@ class ConnectionMonitor {
|
|
|
5366
5365
|
await this.#attemptReconnection();
|
|
5367
5366
|
// Could attempt to find compatible peers or trigger version negotiation
|
|
5368
5367
|
}
|
|
5369
|
-
else {
|
|
5370
|
-
// Reset reconnect attempts on successful connection
|
|
5371
|
-
this.#reconnectAttempts = 0;
|
|
5372
|
-
}
|
|
5373
5368
|
// Log disconnected peers
|
|
5374
5369
|
const disconnectedPeers = this.disconnectedPeers;
|
|
5375
5370
|
if (disconnectedPeers.length > 0) {
|
|
@@ -5392,7 +5387,6 @@ class ConnectionMonitor {
|
|
|
5392
5387
|
if (this.#peerReconnectAttempts[peer.peerId] >= this.#maxReconnectAttempts) {
|
|
5393
5388
|
console.error('❌ Max reconnection attempts reached');
|
|
5394
5389
|
this.#peerReconnectAttempts[peer.peerId] = 0;
|
|
5395
|
-
return;
|
|
5396
5390
|
}
|
|
5397
5391
|
if (!this.#peerReconnectAttempts[peer.peerId]) {
|
|
5398
5392
|
this.#peerReconnectAttempts[peer.peerId] = 0;
|
|
@@ -5418,12 +5412,7 @@ class ConnectionMonitor {
|
|
|
5418
5412
|
// }
|
|
5419
5413
|
}
|
|
5420
5414
|
async #attemptReconnection() {
|
|
5421
|
-
|
|
5422
|
-
console.error('❌ Max reconnection attempts reached');
|
|
5423
|
-
return;
|
|
5424
|
-
}
|
|
5425
|
-
this.#reconnectAttempts++;
|
|
5426
|
-
console.log(`🔄 Attempting reconnection ${this.#reconnectAttempts}/${this.#maxReconnectAttempts}`);
|
|
5415
|
+
console.warn('⚠️ Attempting to reconnect to peers...');
|
|
5427
5416
|
try {
|
|
5428
5417
|
// Try to restart the network
|
|
5429
5418
|
if (globalThis.peernet?.start) {
|
|
@@ -5434,8 +5423,15 @@ class ConnectionMonitor {
|
|
|
5434
5423
|
}
|
|
5435
5424
|
catch (error) {
|
|
5436
5425
|
console.error('❌ Reconnection failed:', error.message);
|
|
5437
|
-
|
|
5438
|
-
|
|
5426
|
+
if (this.#reconnectDelay >= 30000) {
|
|
5427
|
+
console.warn('⚠️ Reconnection delay reached maximum, resetting to 5 seconds');
|
|
5428
|
+
this.#reconnectDelay = 5000;
|
|
5429
|
+
}
|
|
5430
|
+
else {
|
|
5431
|
+
// Exponential backoff
|
|
5432
|
+
this.#reconnectDelay = Math.min(this.#reconnectDelay * 1.5, 30000);
|
|
5433
|
+
console.warn(`⚠️ Increasing reconnection delay to ${this.#reconnectDelay} ms`);
|
|
5434
|
+
}
|
|
5439
5435
|
}
|
|
5440
5436
|
}
|
|
5441
5437
|
async waitForPeers(timeoutMs = 30000) {
|
package/exports/chain.js
CHANGED
|
@@ -1458,7 +1458,6 @@ class VersionControl extends State {
|
|
|
1458
1458
|
class ConnectionMonitor {
|
|
1459
1459
|
#isMonitoring = false;
|
|
1460
1460
|
#checkInterval = null;
|
|
1461
|
-
#reconnectAttempts = 0;
|
|
1462
1461
|
#peerReconnectAttempts = {};
|
|
1463
1462
|
#maxReconnectAttempts = 10;
|
|
1464
1463
|
#reconnectDelay = 5000;
|
|
@@ -1512,10 +1511,6 @@ class ConnectionMonitor {
|
|
|
1512
1511
|
await this.#attemptReconnection();
|
|
1513
1512
|
// Could attempt to find compatible peers or trigger version negotiation
|
|
1514
1513
|
}
|
|
1515
|
-
else {
|
|
1516
|
-
// Reset reconnect attempts on successful connection
|
|
1517
|
-
this.#reconnectAttempts = 0;
|
|
1518
|
-
}
|
|
1519
1514
|
// Log disconnected peers
|
|
1520
1515
|
const disconnectedPeers = this.disconnectedPeers;
|
|
1521
1516
|
if (disconnectedPeers.length > 0) {
|
|
@@ -1538,7 +1533,6 @@ class ConnectionMonitor {
|
|
|
1538
1533
|
if (this.#peerReconnectAttempts[peer.peerId] >= this.#maxReconnectAttempts) {
|
|
1539
1534
|
console.error('❌ Max reconnection attempts reached');
|
|
1540
1535
|
this.#peerReconnectAttempts[peer.peerId] = 0;
|
|
1541
|
-
return;
|
|
1542
1536
|
}
|
|
1543
1537
|
if (!this.#peerReconnectAttempts[peer.peerId]) {
|
|
1544
1538
|
this.#peerReconnectAttempts[peer.peerId] = 0;
|
|
@@ -1564,12 +1558,7 @@ class ConnectionMonitor {
|
|
|
1564
1558
|
// }
|
|
1565
1559
|
}
|
|
1566
1560
|
async #attemptReconnection() {
|
|
1567
|
-
|
|
1568
|
-
console.error('❌ Max reconnection attempts reached');
|
|
1569
|
-
return;
|
|
1570
|
-
}
|
|
1571
|
-
this.#reconnectAttempts++;
|
|
1572
|
-
console.log(`🔄 Attempting reconnection ${this.#reconnectAttempts}/${this.#maxReconnectAttempts}`);
|
|
1561
|
+
console.warn('⚠️ Attempting to reconnect to peers...');
|
|
1573
1562
|
try {
|
|
1574
1563
|
// Try to restart the network
|
|
1575
1564
|
if (globalThis.peernet?.start) {
|
|
@@ -1580,8 +1569,15 @@ class ConnectionMonitor {
|
|
|
1580
1569
|
}
|
|
1581
1570
|
catch (error) {
|
|
1582
1571
|
console.error('❌ Reconnection failed:', error.message);
|
|
1583
|
-
|
|
1584
|
-
|
|
1572
|
+
if (this.#reconnectDelay >= 30000) {
|
|
1573
|
+
console.warn('⚠️ Reconnection delay reached maximum, resetting to 5 seconds');
|
|
1574
|
+
this.#reconnectDelay = 5000;
|
|
1575
|
+
}
|
|
1576
|
+
else {
|
|
1577
|
+
// Exponential backoff
|
|
1578
|
+
this.#reconnectDelay = Math.min(this.#reconnectDelay * 1.5, 30000);
|
|
1579
|
+
console.warn(`⚠️ Increasing reconnection delay to ${this.#reconnectDelay} ms`);
|
|
1580
|
+
}
|
|
1585
1581
|
}
|
|
1586
1582
|
}
|
|
1587
1583
|
async waitForPeers(timeoutMs = 30000) {
|