@leofcoin/chain 1.4.63 → 1.4.65

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.
@@ -8178,11 +8178,8 @@ class Chain extends Contract {
8178
8178
  this.#jail.push(validatorInfo.address);
8179
8179
  }
8180
8180
  async triggerSync() {
8181
- if (this.#chainSyncing)
8182
- return 'already syncing';
8183
8181
  const latest = await this.#getLatestBlock();
8184
- await this.syncChain(latest);
8185
- return 'synced';
8182
+ return this.syncChain(latest);
8186
8183
  }
8187
8184
  async syncChain(lastBlock) {
8188
8185
  if (!lastBlock)
@@ -8215,8 +8212,6 @@ class Chain extends Contract {
8215
8212
  return 'connectionless';
8216
8213
  try {
8217
8214
  await syncPromise(lastBlock);
8218
- if (lastBlock.index === this.#lastBlockInQue?.index || lastBlock.index > this.#lastBlockInQue?.index)
8219
- this.#lastBlockInQue = undefined;
8220
8215
  }
8221
8216
  catch (error) {
8222
8217
  console.log(error);
@@ -8227,10 +8222,12 @@ class Chain extends Contract {
8227
8222
  this.#syncErrorCount = 0;
8228
8223
  return 'errored';
8229
8224
  }
8225
+ if (lastBlock.index === this.#lastBlockInQue?.index)
8226
+ this.#lastBlockInQue = undefined;
8230
8227
  this.#syncErrorCount = 0;
8228
+ this.#chainSyncing = false;
8231
8229
  if (this.#lastBlockInQue)
8232
8230
  return this.syncChain(this.#lastBlockInQue);
8233
- this.#chainSyncing = false;
8234
8231
  return 'synced';
8235
8232
  }
8236
8233
  async #syncChain(lastBlock) {
@@ -1,4 +1,4 @@
1
- import { c as commonjsGlobal, g as getDefaultExportFromCjs } from './node-browser-50ab55fa.js';
1
+ import { c as commonjsGlobal, g as getDefaultExportFromCjs } from './node-browser-4e3729e3.js';
2
2
  import './index-640d9f36.js';
3
3
 
4
4
  function commonjsRequire(path) {
@@ -41079,7 +41079,9 @@ class P2PTClient extends P2PT {
41079
41079
  });
41080
41080
 
41081
41081
  this.on('msg', async (peer, data, id, from) => {
41082
- if (!this.#discovered[peer.id]) {
41082
+ if (!this.#discovered[peer.id] ||
41083
+ this.#discovered[peer.id]?.connected === false ||
41084
+ this.#discovered[peer.id]?.connected === undefined) {
41083
41085
  if (this.#que.has(peer.id)) {
41084
41086
  const set = this.#que.get(peer.id);
41085
41087
  set.add({peer, data, id, from});
@@ -41087,7 +41089,7 @@ class P2PTClient extends P2PT {
41087
41089
  } else {
41088
41090
  this.#que.set(peer.id, new Set([{peer, data, id, from}]));
41089
41091
  }
41090
- } else if (this.#discovered[peer.id]?.connected) {
41092
+ } else if (this.#discovered[peer.id]?.connected === true) {
41091
41093
  this.#discovered[peer.id]?._handleMessage(new Uint8Array(Object.values(data)), id, from);
41092
41094
  this.bw.down += data.length || data.byteLength;
41093
41095
  }
@@ -1,4 +1,4 @@
1
- import { M as MultiWallet, e as encrypt, b as base58$1 } from './node-browser-50ab55fa.js';
1
+ import { M as MultiWallet, e as encrypt, b as base58$1 } from './node-browser-4e3729e3.js';
2
2
  import './index-640d9f36.js';
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { F as FormatInterface } from './node-browser-50ab55fa.js';
1
+ import { F as FormatInterface } from './node-browser-4e3729e3.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-897eebb9-8412bbb8.js');
20269
+ const importee = await import(/* webpackChunkName: "generate-account" */ './index-d89d21c8-48afef1d.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-d4613b80-9bfe9cca.js');
20440
+ } = await import(/* webpackChunkName: "messages" */ './messages-865446ee-90970bdb.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-fdce8059-f1c6a54e.js');
20519
+ const importee = await import('./client-6167d247-17f75c67.js');
20520
20520
  /**
20521
20521
  * @access public
20522
20522
  * @type {PeernetClient}
@@ -1,2 +1,2 @@
1
- export { N as default } from './node-browser-50ab55fa.js';
1
+ export { N as default } from './node-browser-4e3729e3.js';
2
2
  import './index-640d9f36.js';
package/exports/chain.js CHANGED
@@ -764,11 +764,8 @@ class Chain extends Contract {
764
764
  this.#jail.push(validatorInfo.address);
765
765
  }
766
766
  async triggerSync() {
767
- if (this.#chainSyncing)
768
- return 'already syncing';
769
767
  const latest = await this.#getLatestBlock();
770
- await this.syncChain(latest);
771
- return 'synced';
768
+ return this.syncChain(latest);
772
769
  }
773
770
  async syncChain(lastBlock) {
774
771
  if (!lastBlock)
@@ -801,8 +798,6 @@ class Chain extends Contract {
801
798
  return 'connectionless';
802
799
  try {
803
800
  await syncPromise(lastBlock);
804
- if (lastBlock.index === this.#lastBlockInQue?.index || lastBlock.index > this.#lastBlockInQue?.index)
805
- this.#lastBlockInQue = undefined;
806
801
  }
807
802
  catch (error) {
808
803
  console.log(error);
@@ -813,10 +808,12 @@ class Chain extends Contract {
813
808
  this.#syncErrorCount = 0;
814
809
  return 'errored';
815
810
  }
811
+ if (lastBlock.index === this.#lastBlockInQue?.index)
812
+ this.#lastBlockInQue = undefined;
816
813
  this.#syncErrorCount = 0;
814
+ this.#chainSyncing = false;
817
815
  if (this.#lastBlockInQue)
818
816
  return this.syncChain(this.#lastBlockInQue);
819
- this.#chainSyncing = false;
820
817
  return 'synced';
821
818
  }
822
819
  async #syncChain(lastBlock) {
@@ -30,7 +30,7 @@ export default class Chain extends Contract {
30
30
  hash: string;
31
31
  previousHash: string;
32
32
  }>;
33
- triggerSync(): Promise<"synced" | "already syncing">;
33
+ triggerSync(): Promise<chainSyncState>;
34
34
  syncChain(lastBlock: any): Promise<chainSyncState>;
35
35
  getAndPutBlock(hash: string): BlockMessage;
36
36
  resolveBlock(hash: any): any;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leofcoin/chain",
3
- "version": "1.4.63",
3
+ "version": "1.4.65",
4
4
  "description": "Official javascript implementation",
5
5
  "exports": {
6
6
  "./node": "./exports/node.js",