@leofcoin/chain 1.7.93 → 1.7.94
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 +3 -3
- package/exports/browser/{client-BScgNzXE-Vdpk0JDu.js → client-BGaLaHk2-CA-9lfx-.js} +1 -1
- package/exports/browser/{messages-B9TrXtD1-B5p-nLLO.js → messages-BqTna7yM-sC5s4kYG.js} +4 -1
- package/exports/browser/{node-browser-D4im-c4V.js → node-browser-DwZGtboN.js} +20 -11
- package/exports/browser/node-browser.js +1 -1
- package/exports/chain.js +3 -3
- package/package.json +2 -2
package/exports/browser/chain.js
CHANGED
|
@@ -5415,9 +5415,9 @@ class ConnectionMonitor {
|
|
|
5415
5415
|
console.warn('⚠️ Attempting to reconnect to peers...');
|
|
5416
5416
|
try {
|
|
5417
5417
|
// Try to restart the network
|
|
5418
|
-
if (globalThis.peernet?.start) {
|
|
5419
|
-
|
|
5420
|
-
}
|
|
5418
|
+
// if (globalThis.peernet?.start) {
|
|
5419
|
+
// await globalThis.peernet.start()
|
|
5420
|
+
// }
|
|
5421
5421
|
// Wait a bit before next check
|
|
5422
5422
|
await new Promise((resolve) => setTimeout(resolve, this.#reconnectDelay));
|
|
5423
5423
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { F as FormatInterface } from './node-browser-
|
|
1
|
+
import { F as FormatInterface } from './node-browser-DwZGtboN.js';
|
|
2
2
|
import './identity-Cn0iQbY3-CeW0giQS.js';
|
|
3
3
|
import './index-DUfUgiQY.js';
|
|
4
4
|
|
|
@@ -50,6 +50,9 @@ var proto$9 = {
|
|
|
50
50
|
has: Boolean()
|
|
51
51
|
};
|
|
52
52
|
|
|
53
|
+
/**
|
|
54
|
+
* @extends typeof {FormatInterface}
|
|
55
|
+
*/
|
|
53
56
|
class DHTMessageResponse extends FormatInterface {
|
|
54
57
|
get messageName() {
|
|
55
58
|
return 'PeernetDHTMessageResponse'
|
|
@@ -8496,7 +8496,7 @@ class Peernet {
|
|
|
8496
8496
|
this.root = options.root;
|
|
8497
8497
|
const { RequestMessage, ResponseMessage, PeerMessage, PeerMessageResponse, PeernetMessage, DHTMessage, DHTMessageResponse, DataMessage, DataMessageResponse, PsMessage, ChatMessage, PeernetFile
|
|
8498
8498
|
// FolderMessageResponse
|
|
8499
|
-
} = await import(/* webpackChunkName: "messages" */ './messages-
|
|
8499
|
+
} = await import(/* webpackChunkName: "messages" */ './messages-BqTna7yM-sC5s4kYG.js');
|
|
8500
8500
|
/**
|
|
8501
8501
|
* proto Object containing protos
|
|
8502
8502
|
* @type {Object}
|
|
@@ -8590,7 +8590,7 @@ class Peernet {
|
|
|
8590
8590
|
if (this.#starting || this.#started)
|
|
8591
8591
|
return;
|
|
8592
8592
|
this.#starting = true;
|
|
8593
|
-
const importee = await import('./client-
|
|
8593
|
+
const importee = await import('./client-BGaLaHk2-CA-9lfx-.js');
|
|
8594
8594
|
/**
|
|
8595
8595
|
* @access public
|
|
8596
8596
|
* @type {PeernetClient}
|
|
@@ -8738,7 +8738,7 @@ class Peernet {
|
|
|
8738
8738
|
if (proto.name !== 'peernet-dht-response')
|
|
8739
8739
|
throw dhtError(proto.name);
|
|
8740
8740
|
const peerInfo = {
|
|
8741
|
-
|
|
8741
|
+
address: peer.remoteAddress,
|
|
8742
8742
|
id: peerId
|
|
8743
8743
|
};
|
|
8744
8744
|
if (proto.decoded.has)
|
|
@@ -8746,6 +8746,7 @@ class Peernet {
|
|
|
8746
8746
|
}
|
|
8747
8747
|
catch (error) {
|
|
8748
8748
|
console.error(`Error while walking ${peerId}`, error);
|
|
8749
|
+
return undefined;
|
|
8749
8750
|
}
|
|
8750
8751
|
};
|
|
8751
8752
|
let walks = [];
|
|
@@ -8754,7 +8755,7 @@ class Peernet {
|
|
|
8754
8755
|
walks.push(walk(peer, peerId));
|
|
8755
8756
|
}
|
|
8756
8757
|
}
|
|
8757
|
-
return Promise.
|
|
8758
|
+
return Promise.race(walks);
|
|
8758
8759
|
}
|
|
8759
8760
|
/**
|
|
8760
8761
|
* Override DHT behavior, try's finding the content three times
|
|
@@ -8811,18 +8812,26 @@ class Peernet {
|
|
|
8811
8812
|
throw nothingFoundError(hash);
|
|
8812
8813
|
debug(`found ${Object.keys(providers).length} provider(s) for ${hash}`);
|
|
8813
8814
|
// get closest peer on earth
|
|
8814
|
-
|
|
8815
|
+
let closestPeer = await this.dht.closestPeer(Object.values(providers));
|
|
8816
|
+
// fallback to first provider if no closest peer found
|
|
8817
|
+
if (!closestPeer || !closestPeer.id)
|
|
8818
|
+
closestPeer = Object.values(providers)[0];
|
|
8819
|
+
debug(`closest peer for ${hash} is ${closestPeer?.address}`);
|
|
8815
8820
|
// get peer instance by id
|
|
8816
8821
|
if (!closestPeer || !closestPeer.id)
|
|
8817
8822
|
return this.requestData(hash, store?.name || store);
|
|
8818
8823
|
const id = closestPeer.id;
|
|
8819
8824
|
const peer = this.connections[id];
|
|
8825
|
+
if (!peer || !peer?.connected) {
|
|
8826
|
+
this.dht.removeProvider(id, hash);
|
|
8827
|
+
return this.requestData(hash, store?.name || store);
|
|
8828
|
+
}
|
|
8829
|
+
let data = await new globalThis.peernet.protos['peernet-data']({
|
|
8830
|
+
hash,
|
|
8831
|
+
store: store?.name || store
|
|
8832
|
+
});
|
|
8833
|
+
const node = await this.prepareMessage(data);
|
|
8820
8834
|
if (peer?.connected) {
|
|
8821
|
-
let data = await new globalThis.peernet.protos['peernet-data']({
|
|
8822
|
-
hash,
|
|
8823
|
-
store: store?.name || store
|
|
8824
|
-
});
|
|
8825
|
-
const node = await this.prepareMessage(data);
|
|
8826
8835
|
try {
|
|
8827
8836
|
if (peer)
|
|
8828
8837
|
data = await peer.request(node.encoded);
|
|
@@ -8848,10 +8857,10 @@ class Peernet {
|
|
|
8848
8857
|
catch (error) {
|
|
8849
8858
|
debug(`Error while requesting data from ${id}`, error);
|
|
8850
8859
|
// if error, remove provider
|
|
8851
|
-
this.dht.removeProvider(id, hash);
|
|
8852
8860
|
if (this.#peerAttempts[id] > 1) {
|
|
8853
8861
|
this.#peerAttempts[id] = 0;
|
|
8854
8862
|
debug(`Removed provider ${id} for ${hash} after 3 attempts`);
|
|
8863
|
+
this.dht.removeProvider(id, hash);
|
|
8855
8864
|
console.error(nothingFoundError(hash));
|
|
8856
8865
|
return undefined;
|
|
8857
8866
|
}
|
package/exports/chain.js
CHANGED
|
@@ -1561,9 +1561,9 @@ class ConnectionMonitor {
|
|
|
1561
1561
|
console.warn('⚠️ Attempting to reconnect to peers...');
|
|
1562
1562
|
try {
|
|
1563
1563
|
// Try to restart the network
|
|
1564
|
-
if (globalThis.peernet?.start) {
|
|
1565
|
-
|
|
1566
|
-
}
|
|
1564
|
+
// if (globalThis.peernet?.start) {
|
|
1565
|
+
// await globalThis.peernet.start()
|
|
1566
|
+
// }
|
|
1567
1567
|
// Wait a bit before next check
|
|
1568
1568
|
await new Promise((resolve) => setTimeout(resolve, this.#reconnectDelay));
|
|
1569
1569
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leofcoin/chain",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.94",
|
|
4
4
|
"description": "Official javascript implementation",
|
|
5
5
|
"private": false,
|
|
6
6
|
"exports": {
|
|
@@ -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.95",
|
|
73
73
|
"@leofcoin/storage": "^3.5.38",
|
|
74
74
|
"@leofcoin/utils": "^1.1.40",
|
|
75
75
|
"@leofcoin/workers": "^1.5.27",
|