@leofcoin/chain 1.4.54 → 1.4.56

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.
@@ -7884,6 +7884,7 @@ globalThis.BigNumber = BigNumber;
7884
7884
  // check if browser or local
7885
7885
  class Chain extends Contract {
7886
7886
  version;
7887
+ #resolveErrored;
7887
7888
  #state;
7888
7889
  #lastResolved;
7889
7890
  #slotTime = 10000;
@@ -8236,33 +8237,10 @@ class Chain extends Contract {
8236
8237
  if (!peer.version || peer.version !== this.version)
8237
8238
  return;
8238
8239
  const lastBlock = await this.#makeRequest(peer, 'lastBlock');
8239
- if (lastBlock.index > this.#lastBlock?.index) {
8240
+ if (this.#resolveErrored || lastBlock && lastBlock.index > this.#lastBlock?.index) {
8240
8241
  // this.#knownBlocks = await this.#makeRequest(peer, 'knownBlocks')
8241
- try {
8242
- console.log('getting pool');
8243
- let pool = await this.#makeRequest(peer, 'transactionPool');
8244
- console.log('got pool');
8245
- pool = await Promise.all(pool.map(async (hash) => {
8246
- const has = await globalThis.peernet.has(hash);
8247
- return { has, hash };
8248
- }));
8249
- pool = pool.filter(item => !item.has);
8250
- await Promise.all(pool.map(async ({ hash }) => {
8251
- const result = await globalThis.peernet.get(hash);
8252
- // result could be undefined cause invalid/double transactions could be deleted already
8253
- if (!result)
8254
- console.log(result);
8255
- if (result) {
8256
- const node = await new TransactionMessage(result);
8257
- await globalThis.transactionPoolStore.put(await node.hash(), node.encoded);
8258
- }
8259
- }));
8260
- }
8261
- catch (error) {
8262
- console.log(error);
8263
- console.log('error fetching transactionPool');
8264
- }
8265
8242
  console.log(lastBlock);
8243
+ this.#resolveErrored = false;
8266
8244
  if (lastBlock)
8267
8245
  await this.#syncChain(lastBlock);
8268
8246
  if (await this.hasTransactionToHandle())
@@ -8324,6 +8302,7 @@ class Chain extends Contract {
8324
8302
  }
8325
8303
  }
8326
8304
  catch (error) {
8305
+ this.#resolveErrored = true;
8327
8306
  console.error(error);
8328
8307
  }
8329
8308
  }
@@ -1,4 +1,4 @@
1
- import { c as commonjsGlobal, g as getDefaultExportFromCjs } from './node-browser-5484753a.js';
1
+ import { c as commonjsGlobal, g as getDefaultExportFromCjs } from './node-browser-3d505e1f.js';
2
2
  import './index-640d9f36.js';
3
3
 
4
4
  function commonjsRequire(path) {
@@ -40901,6 +40901,8 @@ var P2PT = /*@__PURE__*/getDefaultExportFromCjs(p2pt_umdExports);
40901
40901
 
40902
40902
  class P2PTPeer {
40903
40903
  id;
40904
+ remotePeerId;
40905
+ localPeerId;
40904
40906
  #peerId;
40905
40907
  #channelName
40906
40908
  initiator = false
@@ -40926,8 +40928,10 @@ class P2PTPeer {
40926
40928
  constructor(peer, p2pt, options = {}) {
40927
40929
  this.#connection = peer;
40928
40930
  this.p2pt = p2pt;
40929
- this.id = options.id;
40930
- this.to = options.to;
40931
+
40932
+ this.id = options.id || peer.id;
40933
+ this.localPeerId = this.p2pt.peerId;
40934
+
40931
40935
  this.bw = {
40932
40936
  up: 0,
40933
40937
  down: 0
@@ -1,4 +1,4 @@
1
- import { M as MultiWallet, e as encrypt, b as base58$1 } from './node-browser-5484753a.js';
1
+ import { M as MultiWallet, e as encrypt, b as base58$1 } from './node-browser-3d505e1f.js';
2
2
  import './index-640d9f36.js';
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { F as FormatInterface } from './node-browser-5484753a.js';
1
+ import { F as FormatInterface } from './node-browser-3d505e1f.js';
2
2
  import './index-640d9f36.js';
3
3
 
4
4
  var proto$b = {
@@ -20267,7 +20267,7 @@ class Identity {
20267
20267
  globalThis.peernet.selectedAccount = new TextDecoder().decode(selected);
20268
20268
  }
20269
20269
  else {
20270
- const importee = await import(/* webpackChunkName: "generate-account" */ './index-437bf7cd-47a5a0fb.js');
20270
+ const importee = await import(/* webpackChunkName: "generate-account" */ './index-904b9f85-2d6175c2.js');
20271
20271
  const { identity, accounts } = await importee.default(password, this.network);
20272
20272
  await globalThis.accountStore.put('public', JSON.stringify({ walletId: identity.walletId }));
20273
20273
  await globalThis.walletStore.put('version', String(1));
@@ -20438,7 +20438,7 @@ class Peernet {
20438
20438
  this.root = options.root;
20439
20439
  const { RequestMessage, ResponseMessage, PeerMessage, PeerMessageResponse, PeernetMessage, DHTMessage, DHTMessageResponse, DataMessage, DataMessageResponse, PsMessage, ChatMessage, PeernetFile
20440
20440
  // FolderMessageResponse
20441
- } = await import(/* webpackChunkName: "messages" */ './messages-ccc03e41-b2b7bce7.js');
20441
+ } = await import(/* webpackChunkName: "messages" */ './messages-de2c5670-d99ad896.js');
20442
20442
  /**
20443
20443
  * proto Object containing protos
20444
20444
  * @type {Object}
@@ -20517,7 +20517,7 @@ class Peernet {
20517
20517
  if (this.#starting || this.#started)
20518
20518
  return;
20519
20519
  this.#starting = true;
20520
- const importee = await import('./client-a56e0aac-0ade57cc.js');
20520
+ const importee = await import('./client-d1c29e20-c5d45b87.js');
20521
20521
  /**
20522
20522
  * @access public
20523
20523
  * @type {PeernetClient}
@@ -1,2 +1,2 @@
1
- export { N as default } from './node-browser-5484753a.js';
1
+ export { N as default } from './node-browser-3d505e1f.js';
2
2
  import './index-640d9f36.js';
package/exports/chain.js CHANGED
@@ -470,6 +470,7 @@ globalThis.BigNumber = BigNumber;
470
470
  // check if browser or local
471
471
  class Chain extends Contract {
472
472
  version;
473
+ #resolveErrored;
473
474
  #state;
474
475
  #lastResolved;
475
476
  #slotTime = 10000;
@@ -822,33 +823,10 @@ class Chain extends Contract {
822
823
  if (!peer.version || peer.version !== this.version)
823
824
  return;
824
825
  const lastBlock = await this.#makeRequest(peer, 'lastBlock');
825
- if (lastBlock.index > this.#lastBlock?.index) {
826
+ if (this.#resolveErrored || lastBlock && lastBlock.index > this.#lastBlock?.index) {
826
827
  // this.#knownBlocks = await this.#makeRequest(peer, 'knownBlocks')
827
- try {
828
- console.log('getting pool');
829
- let pool = await this.#makeRequest(peer, 'transactionPool');
830
- console.log('got pool');
831
- pool = await Promise.all(pool.map(async (hash) => {
832
- const has = await globalThis.peernet.has(hash);
833
- return { has, hash };
834
- }));
835
- pool = pool.filter(item => !item.has);
836
- await Promise.all(pool.map(async ({ hash }) => {
837
- const result = await globalThis.peernet.get(hash);
838
- // result could be undefined cause invalid/double transactions could be deleted already
839
- if (!result)
840
- console.log(result);
841
- if (result) {
842
- const node = await new TransactionMessage(result);
843
- await globalThis.transactionPoolStore.put(await node.hash(), node.encoded);
844
- }
845
- }));
846
- }
847
- catch (error) {
848
- console.log(error);
849
- console.log('error fetching transactionPool');
850
- }
851
828
  console.log(lastBlock);
829
+ this.#resolveErrored = false;
852
830
  if (lastBlock)
853
831
  await this.#syncChain(lastBlock);
854
832
  if (await this.hasTransactionToHandle())
@@ -910,6 +888,7 @@ class Chain extends Contract {
910
888
  }
911
889
  }
912
890
  catch (error) {
891
+ this.#resolveErrored = true;
913
892
  console.error(error);
914
893
  }
915
894
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leofcoin/chain",
3
- "version": "1.4.54",
3
+ "version": "1.4.56",
4
4
  "description": "Official javascript implementation",
5
5
  "exports": {
6
6
  "./node": "./exports/node.js",