@leofcoin/chain 1.7.76 → 1.7.78
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/browser-Cjcx-T47-D0KbGYCz.js +38 -0
- package/exports/browser/browser-nu3nKt2I-DENgb7BU.js +132 -0
- package/exports/browser/chain.js +46 -3
- package/exports/browser/{client-DD7vhDK_-BdNAdRzV.js → client-MAPwcc7G-CjrC1JNQ.js} +11 -11
- package/exports/browser/identity-Cn0iQbY3-CeW0giQS.js +17199 -0
- package/exports/browser/{index-Vl0cNziw-Dw2QX2H3.js → index-Biyfi3Iw-BfLCs_Ot.js} +1 -1
- package/exports/browser/index-CPXJrMI6-Bh4f9JBP.js +7580 -0
- package/exports/browser/{messages-CW17jRdc-Dtrj-vba.js → messages-BkkXT6WO-Cd5WEDxx.js} +2 -2
- package/exports/browser/{node-browser-DMmrhyQS.js → node-browser-Ctauqi8V.js} +10 -5
- package/exports/browser/node-browser.js +2 -2
- package/exports/chain.js +46 -3
- package/exports/connection-monitor.d.ts +4 -3
- package/package.json +3 -3
- package/exports/browser/browser-BogfGRzB-D3fc2MzB.js +0 -115
- package/exports/browser/browser-pguCHlVu-pguCHlVu.js +0 -25
- package/exports/browser/identity--VAIVSMm-DTWL357I.js +0 -16705
- package/exports/browser/index-Vgr1JQcP-DNJYAZ_u.js +0 -7417
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { F as FormatInterface } from './node-browser-
|
|
2
|
-
import './identity
|
|
1
|
+
import { F as FormatInterface } from './node-browser-Ctauqi8V.js';
|
|
2
|
+
import './identity-Cn0iQbY3-CeW0giQS.js';
|
|
3
3
|
import './index-DUfUgiQY.js';
|
|
4
4
|
|
|
5
5
|
var proto$b = {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { b as base$1, I as Identity, i as index$4, a as index$5, c as base58$1, d as index$3, e as index$2 } from './identity
|
|
1
|
+
import { b as base$1, I as Identity, i as index$4, a as index$5, c as base58$1, d as index$3, e as index$2 } from './identity-Cn0iQbY3-CeW0giQS.js';
|
|
2
2
|
import { F as FormatInterface$2, T as TransactionMessage, C as ContractMessage, B as BlockMessage, a as BWMessage, b as BWRequestMessage, V as ValidatorMessage } from './index-DUfUgiQY.js';
|
|
3
3
|
|
|
4
4
|
var proto = {
|
|
@@ -8495,7 +8495,7 @@ class Peernet {
|
|
|
8495
8495
|
this.root = options.root;
|
|
8496
8496
|
const { RequestMessage, ResponseMessage, PeerMessage, PeerMessageResponse, PeernetMessage, DHTMessage, DHTMessageResponse, DataMessage, DataMessageResponse, PsMessage, ChatMessage, PeernetFile
|
|
8497
8497
|
// FolderMessageResponse
|
|
8498
|
-
} = await import(/* webpackChunkName: "messages" */ './messages-
|
|
8498
|
+
} = await import(/* webpackChunkName: "messages" */ './messages-BkkXT6WO-Cd5WEDxx.js');
|
|
8499
8499
|
/**
|
|
8500
8500
|
* proto Object containing protos
|
|
8501
8501
|
* @type {Object}
|
|
@@ -8589,7 +8589,7 @@ class Peernet {
|
|
|
8589
8589
|
if (this.#starting || this.#started)
|
|
8590
8590
|
return;
|
|
8591
8591
|
this.#starting = true;
|
|
8592
|
-
const importee = await import('./client-
|
|
8592
|
+
const importee = await import('./client-MAPwcc7G-CjrC1JNQ.js');
|
|
8593
8593
|
/**
|
|
8594
8594
|
* @access public
|
|
8595
8595
|
* @type {PeernetClient}
|
|
@@ -8630,6 +8630,11 @@ class Peernet {
|
|
|
8630
8630
|
};
|
|
8631
8631
|
peer.once('error', onError);
|
|
8632
8632
|
peer.once('connect', async () => {
|
|
8633
|
+
if (!peer.connected) {
|
|
8634
|
+
peer.removeListener('error', onError);
|
|
8635
|
+
debug('Peer not connected');
|
|
8636
|
+
return;
|
|
8637
|
+
}
|
|
8633
8638
|
await peer.send(data, id);
|
|
8634
8639
|
this.bw.up += data.length;
|
|
8635
8640
|
peer.removeListener('error', onError);
|
|
@@ -8739,7 +8744,7 @@ class Peernet {
|
|
|
8739
8744
|
};
|
|
8740
8745
|
let walks = [];
|
|
8741
8746
|
for (const [peerId, peer] of Object.entries(this.connections)) {
|
|
8742
|
-
if (peerId !== this.id) {
|
|
8747
|
+
if (peerId !== this.id && peer.connected) {
|
|
8743
8748
|
walks.push(walk(peer, peerId));
|
|
8744
8749
|
}
|
|
8745
8750
|
}
|
|
@@ -9078,7 +9083,7 @@ globalThis.Peernet = Peernet;
|
|
|
9078
9083
|
var networks = {
|
|
9079
9084
|
leofcoin: {
|
|
9080
9085
|
peach: {
|
|
9081
|
-
stars: ['wss://star
|
|
9086
|
+
stars: ['wss://star.leofcoin.org'] // todo webrtc and bittorent stars
|
|
9082
9087
|
}
|
|
9083
9088
|
}
|
|
9084
9089
|
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { N as default } from './node-browser-
|
|
2
|
-
import './identity
|
|
1
|
+
export { N as default } from './node-browser-Ctauqi8V.js';
|
|
2
|
+
import './identity-Cn0iQbY3-CeW0giQS.js';
|
|
3
3
|
import './index-DUfUgiQY.js';
|
package/exports/chain.js
CHANGED
|
@@ -1165,7 +1165,7 @@ class State extends Contract {
|
|
|
1165
1165
|
const localBlock = await this.lastBlock;
|
|
1166
1166
|
if (!localBlock || Number(localBlock.index) < Number(lastBlock.index)) {
|
|
1167
1167
|
// TODO: check if valid
|
|
1168
|
-
const localIndex = localBlock ? localBlock.index : 0;
|
|
1168
|
+
const localIndex = localBlock ? Number(localBlock.index) : 0;
|
|
1169
1169
|
const index = lastBlock.index;
|
|
1170
1170
|
await this.resolveBlock(lastBlock.hash);
|
|
1171
1171
|
console.log('ok');
|
|
@@ -1446,6 +1446,7 @@ class ConnectionMonitor {
|
|
|
1446
1446
|
#isMonitoring = false;
|
|
1447
1447
|
#checkInterval = null;
|
|
1448
1448
|
#reconnectAttempts = 0;
|
|
1449
|
+
#peerReconnectAttempts = {};
|
|
1449
1450
|
#maxReconnectAttempts = 10;
|
|
1450
1451
|
#reconnectDelay = 5000;
|
|
1451
1452
|
#healthCheckInterval = 10000;
|
|
@@ -1459,11 +1460,12 @@ class ConnectionMonitor {
|
|
|
1459
1460
|
get compatiblePeers() {
|
|
1460
1461
|
return this.connectedPeers.filter((peer) => peer.version === this.#version);
|
|
1461
1462
|
}
|
|
1462
|
-
|
|
1463
|
-
|
|
1463
|
+
get disconnectedPeers() {
|
|
1464
|
+
return Object.values(globalThis.peernet?.connections || {}).filter((peer) => !peer.connected);
|
|
1464
1465
|
}
|
|
1465
1466
|
start(version) {
|
|
1466
1467
|
this.#version = version;
|
|
1468
|
+
console.log(`🔗 Connection Monitor initialized for version: ${this.#version}`);
|
|
1467
1469
|
if (this.#isMonitoring)
|
|
1468
1470
|
return;
|
|
1469
1471
|
this.#isMonitoring = true;
|
|
@@ -1494,12 +1496,24 @@ class ConnectionMonitor {
|
|
|
1494
1496
|
}
|
|
1495
1497
|
else if (compatiblePeers.length === 0) {
|
|
1496
1498
|
console.warn('⚠️ No compatible peers found');
|
|
1499
|
+
await this.#attemptReconnection();
|
|
1497
1500
|
// Could attempt to find compatible peers or trigger version negotiation
|
|
1498
1501
|
}
|
|
1499
1502
|
else {
|
|
1500
1503
|
// Reset reconnect attempts on successful connection
|
|
1501
1504
|
this.#reconnectAttempts = 0;
|
|
1502
1505
|
}
|
|
1506
|
+
// Log disconnected peers
|
|
1507
|
+
const disconnectedPeers = this.disconnectedPeers;
|
|
1508
|
+
if (disconnectedPeers.length > 0) {
|
|
1509
|
+
console.warn(`⚠️ Disconnected peers: ${disconnectedPeers.map((peer) => peer.peerId).join(', ')}`);
|
|
1510
|
+
// Attempt to reconnect each disconnected peer
|
|
1511
|
+
const promises = [];
|
|
1512
|
+
for (const peer of disconnectedPeers) {
|
|
1513
|
+
promises.push(this.#attemptPeerReconnection(peer));
|
|
1514
|
+
}
|
|
1515
|
+
await Promise.all(promises);
|
|
1516
|
+
}
|
|
1503
1517
|
// Publish connection status
|
|
1504
1518
|
globalThis.pubsub?.publish('connection-status', {
|
|
1505
1519
|
connected: connectedPeers.length,
|
|
@@ -1507,6 +1521,35 @@ class ConnectionMonitor {
|
|
|
1507
1521
|
healthy: compatiblePeers.length > 0
|
|
1508
1522
|
});
|
|
1509
1523
|
}
|
|
1524
|
+
async #attemptPeerReconnection(peer) {
|
|
1525
|
+
if (this.#peerReconnectAttempts[peer.peerId] >= this.#maxReconnectAttempts) {
|
|
1526
|
+
console.error('❌ Max reconnection attempts reached');
|
|
1527
|
+
this.#peerReconnectAttempts[peer.peerId] = 0;
|
|
1528
|
+
return;
|
|
1529
|
+
}
|
|
1530
|
+
if (!this.#peerReconnectAttempts[peer.peerId]) {
|
|
1531
|
+
this.#peerReconnectAttempts[peer.peerId] = 0;
|
|
1532
|
+
}
|
|
1533
|
+
this.#peerReconnectAttempts[peer.peerId]++;
|
|
1534
|
+
console.log(`🔄 Attempting reconnection ${this.#peerReconnectAttempts[peer.peerId]}/${this.#maxReconnectAttempts}`);
|
|
1535
|
+
try {
|
|
1536
|
+
const peerId = peer.peerId || peer.id;
|
|
1537
|
+
// Attempt to reconnect the specific peer
|
|
1538
|
+
await peernet.client.reconnect(peerId, globalThis.peernet?.stars[0]);
|
|
1539
|
+
}
|
|
1540
|
+
catch (error) {
|
|
1541
|
+
console.error('❌ Reconnection failed:', error.message);
|
|
1542
|
+
}
|
|
1543
|
+
// // Try to restart the network
|
|
1544
|
+
// if (globalThis.peernet?.start) {
|
|
1545
|
+
// await globalThis.peernet.start()
|
|
1546
|
+
// } else {
|
|
1547
|
+
// console.warn('⚠️ Peernet start method not available, skipping reconnection')
|
|
1548
|
+
// }
|
|
1549
|
+
// } catch (error) {
|
|
1550
|
+
// console.error('❌ Reconnection failed:', error.message)
|
|
1551
|
+
// }
|
|
1552
|
+
}
|
|
1510
1553
|
async #attemptReconnection() {
|
|
1511
1554
|
if (this.#reconnectAttempts >= this.#maxReconnectAttempts) {
|
|
1512
1555
|
console.error('❌ Max reconnection attempts reached');
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
import Peer from '@netpeer/swarm/peer';
|
|
1
2
|
/**
|
|
2
3
|
* Connection Monitor - Monitors peer connections and handles reconnection logic
|
|
3
4
|
*/
|
|
4
5
|
export default class ConnectionMonitor {
|
|
5
6
|
#private;
|
|
6
7
|
get isMonitoring(): boolean;
|
|
7
|
-
get connectedPeers():
|
|
8
|
-
get compatiblePeers():
|
|
9
|
-
|
|
8
|
+
get connectedPeers(): Peer[];
|
|
9
|
+
get compatiblePeers(): Peer[];
|
|
10
|
+
get disconnectedPeers(): Peer[];
|
|
10
11
|
start(version: any): void;
|
|
11
12
|
stop(): void;
|
|
12
13
|
waitForPeers(timeoutMs?: number): Promise<boolean>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leofcoin/chain",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.78",
|
|
4
4
|
"description": "Official javascript implementation",
|
|
5
5
|
"private": false,
|
|
6
6
|
"exports": {
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"@rollup/plugin-typescript": "^12.1.4",
|
|
56
56
|
"@types/semver": "^7.7.0",
|
|
57
57
|
"@vandeurenglenn/debug": "^1.2.6",
|
|
58
|
-
"rollup": "^4.
|
|
58
|
+
"rollup": "^4.45.1",
|
|
59
59
|
"rollup-plugin-modify": "^3.0.0",
|
|
60
60
|
"tape": "^5.9.0",
|
|
61
61
|
"tslib": "^2.8.1"
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"@leofcoin/messages": "^1.4.40",
|
|
70
70
|
"@leofcoin/multi-wallet": "^3.1.8",
|
|
71
71
|
"@leofcoin/networks": "^1.1.25",
|
|
72
|
-
"@leofcoin/peernet": "^1.1.
|
|
72
|
+
"@leofcoin/peernet": "^1.1.87",
|
|
73
73
|
"@leofcoin/storage": "^3.5.38",
|
|
74
74
|
"@leofcoin/utils": "^1.1.39",
|
|
75
75
|
"@leofcoin/workers": "^1.5.23",
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import { g as getDefaultExportFromCjs } from './identity--VAIVSMm-DTWL357I.js';
|
|
2
|
-
|
|
3
|
-
var global;
|
|
4
|
-
var hasRequiredGlobal;
|
|
5
|
-
|
|
6
|
-
function requireGlobal () {
|
|
7
|
-
if (hasRequiredGlobal) return global;
|
|
8
|
-
hasRequiredGlobal = 1;
|
|
9
|
-
var naiveFallback = function () {
|
|
10
|
-
if (typeof self === "object" && self) return self;
|
|
11
|
-
if (typeof window === "object" && window) return window;
|
|
12
|
-
throw new Error("Unable to resolve global `this`");
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
global = (function () {
|
|
16
|
-
if (this) return this;
|
|
17
|
-
|
|
18
|
-
// Unexpected strict mode (may happen if e.g. bundled into ESM module)
|
|
19
|
-
|
|
20
|
-
// Fallback to standard globalThis if available
|
|
21
|
-
if (typeof globalThis === "object" && globalThis) return globalThis;
|
|
22
|
-
|
|
23
|
-
// Thanks @mathiasbynens -> https://mathiasbynens.be/notes/globalthis
|
|
24
|
-
// In all ES5+ engines global object inherits from Object.prototype
|
|
25
|
-
// (if you approached one that doesn't please report)
|
|
26
|
-
try {
|
|
27
|
-
Object.defineProperty(Object.prototype, "__global__", {
|
|
28
|
-
get: function () { return this; },
|
|
29
|
-
configurable: true
|
|
30
|
-
});
|
|
31
|
-
} catch (error) {
|
|
32
|
-
// Unfortunate case of updates to Object.prototype being restricted
|
|
33
|
-
// via preventExtensions, seal or freeze
|
|
34
|
-
return naiveFallback();
|
|
35
|
-
}
|
|
36
|
-
try {
|
|
37
|
-
// Safari case (window.__global__ works, but __global__ does not)
|
|
38
|
-
if (!__global__) return naiveFallback();
|
|
39
|
-
return __global__;
|
|
40
|
-
} finally {
|
|
41
|
-
delete Object.prototype.__global__;
|
|
42
|
-
}
|
|
43
|
-
})();
|
|
44
|
-
return global;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
var version$1 = "1.0.35";
|
|
48
|
-
var require$$0 = {
|
|
49
|
-
version: version$1};
|
|
50
|
-
|
|
51
|
-
var version = require$$0.version;
|
|
52
|
-
|
|
53
|
-
var _globalThis;
|
|
54
|
-
if (typeof globalThis === 'object') {
|
|
55
|
-
_globalThis = globalThis;
|
|
56
|
-
} else {
|
|
57
|
-
try {
|
|
58
|
-
_globalThis = requireGlobal();
|
|
59
|
-
} catch (error) {
|
|
60
|
-
} finally {
|
|
61
|
-
if (!_globalThis && typeof window !== 'undefined') { _globalThis = window; }
|
|
62
|
-
if (!_globalThis) { throw new Error('Could not determine global this'); }
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
var NativeWebSocket = _globalThis.WebSocket || _globalThis.MozWebSocket;
|
|
67
|
-
var websocket_version = version;
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Expose a W3C WebSocket class with just one or two arguments.
|
|
72
|
-
*/
|
|
73
|
-
function W3CWebSocket(uri, protocols) {
|
|
74
|
-
var native_instance;
|
|
75
|
-
|
|
76
|
-
if (protocols) {
|
|
77
|
-
native_instance = new NativeWebSocket(uri, protocols);
|
|
78
|
-
}
|
|
79
|
-
else {
|
|
80
|
-
native_instance = new NativeWebSocket(uri);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* 'native_instance' is an instance of nativeWebSocket (the browser's WebSocket
|
|
85
|
-
* class). Since it is an Object it will be returned as it is when creating an
|
|
86
|
-
* instance of W3CWebSocket via 'new W3CWebSocket()'.
|
|
87
|
-
*
|
|
88
|
-
* ECMAScript 5: http://bclary.com/2004/11/07/#a-13.2.2
|
|
89
|
-
*/
|
|
90
|
-
return native_instance;
|
|
91
|
-
}
|
|
92
|
-
if (NativeWebSocket) {
|
|
93
|
-
['CONNECTING', 'OPEN', 'CLOSING', 'CLOSED'].forEach(function(prop) {
|
|
94
|
-
Object.defineProperty(W3CWebSocket, prop, {
|
|
95
|
-
get: function() { return NativeWebSocket[prop]; }
|
|
96
|
-
});
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Module exports.
|
|
102
|
-
*/
|
|
103
|
-
var browser = {
|
|
104
|
-
'w3cwebsocket' : NativeWebSocket ? W3CWebSocket : null,
|
|
105
|
-
'version' : websocket_version
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
var browser$1 = /*@__PURE__*/getDefaultExportFromCjs(browser);
|
|
109
|
-
|
|
110
|
-
var browser$2 = /*#__PURE__*/Object.freeze({
|
|
111
|
-
__proto__: null,
|
|
112
|
-
default: browser$1
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
export { browser$2 as b };
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
var browser$1 = {};
|
|
2
|
-
|
|
3
|
-
browser$1.MediaStream = window.MediaStream;
|
|
4
|
-
browser$1.MediaStreamTrack = window.MediaStreamTrack;
|
|
5
|
-
browser$1.RTCDataChannel = window.RTCDataChannel;
|
|
6
|
-
browser$1.RTCDataChannelEvent = window.RTCDataChannelEvent;
|
|
7
|
-
browser$1.RTCDtlsTransport = window.RTCDtlsTransport;
|
|
8
|
-
browser$1.RTCIceCandidate = window.RTCIceCandidate;
|
|
9
|
-
browser$1.RTCIceTransport = window.RTCIceTransport;
|
|
10
|
-
browser$1.RTCPeerConnection = window.RTCPeerConnection;
|
|
11
|
-
browser$1.RTCPeerConnectionIceEvent = window.RTCPeerConnectionIceEvent;
|
|
12
|
-
browser$1.RTCRtpReceiver = window.RTCRtpReceiver;
|
|
13
|
-
browser$1.RTCRtpSender = window.RTCRtpSender;
|
|
14
|
-
browser$1.RTCRtpTransceiver = window.RTCRtpTransceiver;
|
|
15
|
-
browser$1.RTCSctpTransport = window.RTCSctpTransport;
|
|
16
|
-
browser$1.RTCSessionDescription = window.RTCSessionDescription;
|
|
17
|
-
browser$1.getUserMedia = window.getUserMedia;
|
|
18
|
-
browser$1.mediaDevices = navigator.mediaDevices;
|
|
19
|
-
|
|
20
|
-
var browser = /*#__PURE__*/Object.freeze({
|
|
21
|
-
__proto__: null,
|
|
22
|
-
default: browser$1
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
export { browser as b };
|