@leofcoin/chain 1.7.80 → 1.7.82

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.
@@ -1,4 +1,4 @@
1
- import { L as LittlePubSub } from './node-browser-CMsWOKW1.js';
1
+ import { L as LittlePubSub } from './node-browser-Bgru0CmY.js';
2
2
  import './identity-Cn0iQbY3-CeW0giQS.js';
3
3
  import './index-DUfUgiQY.js';
4
4
 
@@ -526,6 +526,22 @@ class Client {
526
526
  }
527
527
  debug(`peer ${id} left`);
528
528
  };
529
+ connect(peerId, star, initiator = true) {
530
+ if (this.#connections[peerId]) {
531
+ debug(`peer ${peerId} already connected`);
532
+ return;
533
+ }
534
+ if (this.#stars[star]?.connectionState() !== 'open') {
535
+ console.warn(`Star ${star} is not connected, cannot reconnect to peer ${peerId}`);
536
+ return;
537
+ }
538
+ this.#createRTCPeerConnection(peerId, star, this.version, initiator);
539
+ }
540
+ reconnect(peerId, star, initiator = true) {
541
+ delete this.#connections[peerId];
542
+ debug(`reconnecting to peer ${peerId}`);
543
+ return this.connect(peerId, star, initiator);
544
+ }
529
545
  #createRTCPeerConnection = (peerId, star, version, initiator = false) => {
530
546
  const peer = new Peer({
531
547
  initiator: initiator,
@@ -1,4 +1,4 @@
1
- import { F as FormatInterface } from './node-browser-CMsWOKW1.js';
1
+ import { F as FormatInterface } from './node-browser-Bgru0CmY.js';
2
2
  import './identity-Cn0iQbY3-CeW0giQS.js';
3
3
  import './index-DUfUgiQY.js';
4
4
 
@@ -8385,6 +8385,7 @@ class Peernet {
8385
8385
  _peerHandler;
8386
8386
  protos;
8387
8387
  version;
8388
+ #peerAttempts = {};
8388
8389
  /**
8389
8390
  * @access public
8390
8391
  * @param {Object} options
@@ -8495,7 +8496,7 @@ class Peernet {
8495
8496
  this.root = options.root;
8496
8497
  const { RequestMessage, ResponseMessage, PeerMessage, PeerMessageResponse, PeernetMessage, DHTMessage, DHTMessageResponse, DataMessage, DataMessageResponse, PsMessage, ChatMessage, PeernetFile
8497
8498
  // FolderMessageResponse
8498
- } = await import(/* webpackChunkName: "messages" */ './messages-D9OyBKBu-D43yTTSZ.js');
8499
+ } = await import(/* webpackChunkName: "messages" */ './messages-PrGKIaCz-DSaD3Nk1.js');
8499
8500
  /**
8500
8501
  * proto Object containing protos
8501
8502
  * @type {Object}
@@ -8589,7 +8590,7 @@ class Peernet {
8589
8590
  if (this.#starting || this.#started)
8590
8591
  return;
8591
8592
  this.#starting = true;
8592
- const importee = await import('./client-D7CuvpPv-YmUgOecm.js');
8593
+ const importee = await import('./client-CWo3zJ1j-DAaJBi_R.js');
8593
8594
  /**
8594
8595
  * @access public
8595
8596
  * @type {PeernetClient}
@@ -8848,7 +8849,14 @@ class Peernet {
8848
8849
  debug(`Error while requesting data from ${id}`, error);
8849
8850
  // if error, remove provider
8850
8851
  this.dht.removeProvider(id, hash);
8851
- // and try again
8852
+ if (this.#peerAttempts[id] > 3) {
8853
+ this.#peerAttempts[id] = 0;
8854
+ debug(`Removed provider ${id} for ${hash} after 3 attempts`);
8855
+ throw nothingFoundError(hash);
8856
+ }
8857
+ if (this.#peerAttempts[id] === undefined)
8858
+ this.#peerAttempts[id] = 0;
8859
+ this.#peerAttempts[id]++;
8852
8860
  return this.requestData(hash, store?.name || store);
8853
8861
  }
8854
8862
  // this.put(hash, proto.decoded.data)
@@ -1,3 +1,3 @@
1
- export { N as default } from './node-browser-CMsWOKW1.js';
1
+ export { N as default } from './node-browser-Bgru0CmY.js';
2
2
  import './identity-Cn0iQbY3-CeW0giQS.js';
3
3
  import './index-DUfUgiQY.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leofcoin/chain",
3
- "version": "1.7.80",
3
+ "version": "1.7.82",
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.88",
72
+ "@leofcoin/peernet": "^1.1.91",
73
73
  "@leofcoin/storage": "^3.5.38",
74
74
  "@leofcoin/utils": "^1.1.39",
75
75
  "@leofcoin/workers": "^1.5.23",