@leofcoin/chain 1.4.61 → 1.4.63

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 { c as commonjsGlobal, g as getDefaultExportFromCjs } from './node-browser-7733e2c1.js';
1
+ import { c as commonjsGlobal, g as getDefaultExportFromCjs } from './node-browser-50ab55fa.js';
2
2
  import './index-640d9f36.js';
3
3
 
4
4
  function commonjsRequire(path) {
@@ -41023,6 +41023,8 @@ class P2PTClient extends P2PT {
41023
41023
 
41024
41024
  }
41025
41025
 
41026
+ #que = new Map()
41027
+
41026
41028
  bw = {
41027
41029
  up: 0,
41028
41030
  down: 0
@@ -41051,8 +41053,22 @@ class P2PTClient extends P2PT {
41051
41053
  });
41052
41054
 
41053
41055
  this.on('peerconnect', async (peer) => {
41054
- this.#discovered[peer.id] = await new P2PTPeer(peer, this);
41056
+ if (!this.#discovered[peer.id]) this.#discovered[peer.id] = await new P2PTPeer(peer, this);
41055
41057
  if (this.#discovered[peer.id].connected) pubsub.publish('peer:discovered', this.#discovered[peer.id]);
41058
+
41059
+ if (this.#que.has(peer.id)) {
41060
+ const set = this.#que.get(peer.id);
41061
+
41062
+ for (const item of set) {
41063
+ if (this.#discovered[peer.id]?.connected) {
41064
+ this.#discovered[peer.id]?._handleMessage(new Uint8Array(Object.values(item.data)), item.id, item.from);
41065
+ this.bw.down += item.data.length || item.data.byteLength;
41066
+ set.delete(item);
41067
+ }
41068
+ }
41069
+ if (set.size === 0) this.#que.delete(peer.id);
41070
+ else this.#que.set(peer.id, set);
41071
+ }
41056
41072
  });
41057
41073
 
41058
41074
  this.on('peerclose', async (peer) => {
@@ -41063,14 +41079,18 @@ class P2PTClient extends P2PT {
41063
41079
  });
41064
41080
 
41065
41081
  this.on('msg', async (peer, data, id, from) => {
41066
- const hasPeer = this.#discovered[peer.id];
41067
- if (!hasPeer) this.#discovered[peer.id] = await new P2PTPeer(peer, this);
41068
-
41069
- if (this.#discovered[peer.id].connected) {
41082
+ if (!this.#discovered[peer.id]) {
41083
+ if (this.#que.has(peer.id)) {
41084
+ const set = this.#que.get(peer.id);
41085
+ set.add({peer, data, id, from});
41086
+ this.#que.set(peer.id, set);
41087
+ } else {
41088
+ this.#que.set(peer.id, new Set([{peer, data, id, from}]));
41089
+ }
41090
+ } else if (this.#discovered[peer.id]?.connected) {
41070
41091
  this.#discovered[peer.id]?._handleMessage(new Uint8Array(Object.values(data)), id, from);
41071
41092
  this.bw.down += data.length || data.byteLength;
41072
41093
  }
41073
-
41074
41094
  });
41075
41095
 
41076
41096
  this.on('data', async (peer, data) => {
@@ -1,4 +1,4 @@
1
- import { M as MultiWallet, e as encrypt, b as base58$1 } from './node-browser-7733e2c1.js';
1
+ import { M as MultiWallet, e as encrypt, b as base58$1 } from './node-browser-50ab55fa.js';
2
2
  import './index-640d9f36.js';
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { F as FormatInterface } from './node-browser-7733e2c1.js';
1
+ import { F as FormatInterface } from './node-browser-50ab55fa.js';
2
2
  import './index-640d9f36.js';
3
3
 
4
4
  var proto$b = {
@@ -20266,7 +20266,7 @@ class Identity {
20266
20266
  globalThis.peernet.selectedAccount = new TextDecoder().decode(selected);
20267
20267
  }
20268
20268
  else {
20269
- const importee = await import(/* webpackChunkName: "generate-account" */ './index-f2f8db5e-087c8b04.js');
20269
+ const importee = await import(/* webpackChunkName: "generate-account" */ './index-897eebb9-8412bbb8.js');
20270
20270
  const { identity, accounts } = await importee.default(password, this.network);
20271
20271
  await globalThis.accountStore.put('public', JSON.stringify({ walletId: identity.walletId }));
20272
20272
  await globalThis.walletStore.put('version', String(1));
@@ -20437,7 +20437,7 @@ class Peernet {
20437
20437
  this.root = options.root;
20438
20438
  const { RequestMessage, ResponseMessage, PeerMessage, PeerMessageResponse, PeernetMessage, DHTMessage, DHTMessageResponse, DataMessage, DataMessageResponse, PsMessage, ChatMessage, PeernetFile
20439
20439
  // FolderMessageResponse
20440
- } = await import(/* webpackChunkName: "messages" */ './messages-fc7c059d-c1b190ab.js');
20440
+ } = await import(/* webpackChunkName: "messages" */ './messages-d4613b80-9bfe9cca.js');
20441
20441
  /**
20442
20442
  * proto Object containing protos
20443
20443
  * @type {Object}
@@ -20516,7 +20516,7 @@ class Peernet {
20516
20516
  if (this.#starting || this.#started)
20517
20517
  return;
20518
20518
  this.#starting = true;
20519
- const importee = await import('./client-c3673dc8-4e2f093c.js');
20519
+ const importee = await import('./client-fdce8059-f1c6a54e.js');
20520
20520
  /**
20521
20521
  * @access public
20522
20522
  * @type {PeernetClient}
@@ -1,2 +1,2 @@
1
- export { N as default } from './node-browser-7733e2c1.js';
1
+ export { N as default } from './node-browser-50ab55fa.js';
2
2
  import './index-640d9f36.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leofcoin/chain",
3
- "version": "1.4.61",
3
+ "version": "1.4.63",
4
4
  "description": "Official javascript implementation",
5
5
  "exports": {
6
6
  "./node": "./exports/node.js",
@@ -58,7 +58,7 @@
58
58
  "@leofcoin/messages": "^1.3.7",
59
59
  "@leofcoin/multi-wallet": "^2.1.1",
60
60
  "@leofcoin/networks": "^1.0.0",
61
- "@leofcoin/peernet": "^1.1.12",
61
+ "@leofcoin/peernet": "^1.1.37",
62
62
  "@leofcoin/peernet-swarm": "^1.0.0",
63
63
  "@leofcoin/storage": "^3.0.6",
64
64
  "@leofcoin/utils": "^1.1.4",