@leofcoin/peernet 1.1.86 → 1.1.87

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 './peernet-CIHG3A1i.js';
1
+ import { L as LittlePubSub } from './peernet-P6qb1z0Q.js';
2
2
  import './identity-Cn0iQbY3.js';
3
3
  import './value-C3vAp-wb.js';
4
4
 
@@ -1,4 +1,4 @@
1
- import { F as FormatInterface } from './peernet-CIHG3A1i.js';
1
+ import { F as FormatInterface } from './peernet-P6qb1z0Q.js';
2
2
  import './identity-Cn0iQbY3.js';
3
3
  import './value-C3vAp-wb.js';
4
4
 
@@ -8371,7 +8371,7 @@ class Peernet {
8371
8371
  this.root = options.root;
8372
8372
  const { RequestMessage, ResponseMessage, PeerMessage, PeerMessageResponse, PeernetMessage, DHTMessage, DHTMessageResponse, DataMessage, DataMessageResponse, PsMessage, ChatMessage, PeernetFile
8373
8373
  // FolderMessageResponse
8374
- } = await import(/* webpackChunkName: "messages" */ './messages-CT983-_h.js');
8374
+ } = await import(/* webpackChunkName: "messages" */ './messages-BkkXT6WO.js');
8375
8375
  /**
8376
8376
  * proto Object containing protos
8377
8377
  * @type {Object}
@@ -8465,7 +8465,7 @@ class Peernet {
8465
8465
  if (this.#starting || this.#started)
8466
8466
  return;
8467
8467
  this.#starting = true;
8468
- const importee = await import('./client-Db0RyH-f.js');
8468
+ const importee = await import('./client-MAPwcc7G.js');
8469
8469
  /**
8470
8470
  * @access public
8471
8471
  * @type {PeernetClient}
@@ -8506,6 +8506,11 @@ class Peernet {
8506
8506
  };
8507
8507
  peer.once('error', onError);
8508
8508
  peer.once('connect', async () => {
8509
+ if (!peer.connected) {
8510
+ peer.removeListener('error', onError);
8511
+ debug('Peer not connected');
8512
+ return;
8513
+ }
8509
8514
  await peer.send(data, id);
8510
8515
  this.bw.up += data.length;
8511
8516
  peer.removeListener('error', onError);
@@ -8615,7 +8620,7 @@ class Peernet {
8615
8620
  };
8616
8621
  let walks = [];
8617
8622
  for (const [peerId, peer] of Object.entries(this.connections)) {
8618
- if (peerId !== this.id) {
8623
+ if (peerId !== this.id && peer.connected) {
8619
8624
  walks.push(walk(peer, peerId));
8620
8625
  }
8621
8626
  }
@@ -1,3 +1,3 @@
1
- export { P as default } from './peernet-CIHG3A1i.js';
1
+ export { P as default } from './peernet-P6qb1z0Q.js';
2
2
  import './identity-Cn0iQbY3.js';
3
3
  import './value-C3vAp-wb.js';
@@ -587,6 +587,11 @@ class Peernet {
587
587
  };
588
588
  peer.once('error', onError);
589
589
  peer.once('connect', async () => {
590
+ if (!peer.connected) {
591
+ peer.removeListener('error', onError);
592
+ debug('Peer not connected');
593
+ return;
594
+ }
590
595
  await peer.send(data, id);
591
596
  this.bw.up += data.length;
592
597
  peer.removeListener('error', onError);
@@ -696,7 +701,7 @@ class Peernet {
696
701
  };
697
702
  let walks = [];
698
703
  for (const [peerId, peer] of Object.entries(this.connections)) {
699
- if (peerId !== this.id) {
704
+ if (peerId !== this.id && peer.connected) {
700
705
  walks.push(walk(peer, peerId));
701
706
  }
702
707
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leofcoin/peernet",
3
- "version": "1.1.86",
3
+ "version": "1.1.87",
4
4
  "description": "",
5
5
  "browser": "./exports/browser/peernet.js",
6
6
  "exports": {
@@ -37,7 +37,7 @@
37
37
  "@leofcoin/identity-utils": "^1.0.2",
38
38
  "@leofcoin/multi-wallet": "^3.1.8",
39
39
  "@leofcoin/storage": "^3.5.38",
40
- "@netpeer/swarm": "^0.8.19",
40
+ "@netpeer/swarm": "^0.8.20",
41
41
  "@vandeurenglenn/base32": "^1.2.4",
42
42
  "@vandeurenglenn/base58": "^1.1.9",
43
43
  "@vandeurenglenn/debug": "^1.2.6",
package/src/peernet.ts CHANGED
@@ -358,6 +358,11 @@ export default class Peernet {
358
358
  }
359
359
  peer.once('error', onError)
360
360
  peer.once('connect', async () => {
361
+ if (!peer.connected) {
362
+ peer.removeListener('error', onError)
363
+ debug('Peer not connected')
364
+ return
365
+ }
361
366
  await peer.send(data, id)
362
367
  this.bw.up += data.length
363
368
  peer.removeListener('error', onError)
@@ -476,7 +481,7 @@ export default class Peernet {
476
481
  }
477
482
  let walks = []
478
483
  for (const [peerId, peer] of Object.entries(this.connections)) {
479
- if (peerId !== this.id) {
484
+ if (peerId !== this.id && peer.connected) {
480
485
  walks.push(walk(peer, peerId))
481
486
  }
482
487
  }