@leofcoin/chain 1.7.79 → 1.7.80
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/{client-MAPwcc7G-CjrC1JNQ.js → client-D7CuvpPv-YmUgOecm.js} +1 -1
- package/exports/browser/{messages-BkkXT6WO-Cd5WEDxx.js → messages-D9OyBKBu-D43yTTSZ.js} +1 -1
- package/exports/browser/{node-browser-Ctauqi8V.js → node-browser-CMsWOKW1.js} +45 -29
- package/exports/browser/node-browser.js +1 -1
- package/package.json +2 -2
|
@@ -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-D9OyBKBu-D43yTTSZ.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-D7CuvpPv-YmUgOecm.js');
|
|
8593
8593
|
/**
|
|
8594
8594
|
* @access public
|
|
8595
8595
|
* @type {PeernetClient}
|
|
@@ -8730,17 +8730,22 @@ class Peernet {
|
|
|
8730
8730
|
const data = await new globalThis.peernet.protos['peernet-dht']({ hash });
|
|
8731
8731
|
const walk = async (peer, peerId) => {
|
|
8732
8732
|
const node = await this.prepareMessage(data);
|
|
8733
|
-
|
|
8734
|
-
|
|
8735
|
-
|
|
8736
|
-
|
|
8737
|
-
|
|
8738
|
-
|
|
8739
|
-
|
|
8740
|
-
|
|
8741
|
-
|
|
8742
|
-
|
|
8743
|
-
|
|
8733
|
+
try {
|
|
8734
|
+
let result = await peer.request(node.encoded);
|
|
8735
|
+
result = new Uint8Array(Object.values(result));
|
|
8736
|
+
const proto = await protoFor(result);
|
|
8737
|
+
if (proto.name !== 'peernet-dht-response')
|
|
8738
|
+
throw dhtError(proto.name);
|
|
8739
|
+
const peerInfo = {
|
|
8740
|
+
...peer.connectionStats,
|
|
8741
|
+
id: peerId
|
|
8742
|
+
};
|
|
8743
|
+
if (proto.decoded.has)
|
|
8744
|
+
this.dht.addProvider(peerInfo, proto.decoded.hash);
|
|
8745
|
+
}
|
|
8746
|
+
catch (error) {
|
|
8747
|
+
console.error(`Error while walking ${peerId}`, error);
|
|
8748
|
+
}
|
|
8744
8749
|
};
|
|
8745
8750
|
let walks = [];
|
|
8746
8751
|
for (const [peerId, peer] of Object.entries(this.connections)) {
|
|
@@ -8817,24 +8822,35 @@ class Peernet {
|
|
|
8817
8822
|
store: store?.name || store
|
|
8818
8823
|
});
|
|
8819
8824
|
const node = await this.prepareMessage(data);
|
|
8820
|
-
|
|
8821
|
-
|
|
8822
|
-
|
|
8823
|
-
|
|
8824
|
-
|
|
8825
|
-
|
|
8826
|
-
|
|
8827
|
-
const
|
|
8828
|
-
|
|
8829
|
-
|
|
8825
|
+
try {
|
|
8826
|
+
if (peer)
|
|
8827
|
+
data = await peer.request(node.encoded);
|
|
8828
|
+
else {
|
|
8829
|
+
// fallback and try every provider found
|
|
8830
|
+
const promises = [];
|
|
8831
|
+
const providers = await this.providersFor(hash, store);
|
|
8832
|
+
for (const provider of Object.values(providers)) {
|
|
8833
|
+
const peer = this.connections[provider.id];
|
|
8834
|
+
if (peer)
|
|
8835
|
+
promises.push(peer.request(node.encoded));
|
|
8836
|
+
}
|
|
8837
|
+
data = await Promise.race(promises);
|
|
8830
8838
|
}
|
|
8831
|
-
|
|
8839
|
+
if (data)
|
|
8840
|
+
data = new Uint8Array(Object.values(data));
|
|
8841
|
+
if (!data || data.length === 0)
|
|
8842
|
+
throw nothingFoundError(hash);
|
|
8843
|
+
const proto = await protoFor(data);
|
|
8844
|
+
// TODO: store data automaticly or not
|
|
8845
|
+
return BufferToUint8Array(proto.decoded.data);
|
|
8846
|
+
}
|
|
8847
|
+
catch (error) {
|
|
8848
|
+
debug(`Error while requesting data from ${id}`, error);
|
|
8849
|
+
// if error, remove provider
|
|
8850
|
+
this.dht.removeProvider(id, hash);
|
|
8851
|
+
// and try again
|
|
8852
|
+
return this.requestData(hash, store?.name || store);
|
|
8832
8853
|
}
|
|
8833
|
-
if (data)
|
|
8834
|
-
data = new Uint8Array(Object.values(data));
|
|
8835
|
-
const proto = await protoFor(data);
|
|
8836
|
-
// TODO: store data automaticly or not
|
|
8837
|
-
return BufferToUint8Array(proto.decoded.data);
|
|
8838
8854
|
// this.put(hash, proto.decoded.data)
|
|
8839
8855
|
}
|
|
8840
8856
|
else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leofcoin/chain",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.80",
|
|
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.88",
|
|
73
73
|
"@leofcoin/storage": "^3.5.38",
|
|
74
74
|
"@leofcoin/utils": "^1.1.39",
|
|
75
75
|
"@leofcoin/workers": "^1.5.23",
|