@leofcoin/chain 1.5.17 → 1.5.19

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.
@@ -1528,9 +1528,10 @@ class State extends Contract {
1528
1528
  await globalThis.transactionPoolStore.delete(hash);
1529
1529
  console.log('removing invalid transaction');
1530
1530
  if (isExecutionError(error)) {
1531
- console.log('removing invalid block');
1531
+ console.log(`removing invalid block ${block.index}`);
1532
1532
  await globalThis.blockStore.delete(await (await new BlockMessage(block)).hash());
1533
- blocks.splice(block.index - 1, 1);
1533
+ const deletedBlock = blocks.splice(block.index, 1);
1534
+ console.log(`removed block ${deletedBlock[0].index}`);
1534
1535
  return this.#loadBlocks(blocks);
1535
1536
  }
1536
1537
  console.log(error);
@@ -1583,6 +1584,11 @@ class State extends Contract {
1583
1584
  const latest = await this.#getLatestBlock();
1584
1585
  return this.syncChain(latest);
1585
1586
  }
1587
+ async triggerLoad() {
1588
+ if (this.#blocks.length > 0) {
1589
+ this.#machine = await new Machine(this.#blocks);
1590
+ }
1591
+ }
1586
1592
  }
1587
1593
 
1588
1594
  globalThis.BigNumber = BigNumber;
package/exports/chain.js CHANGED
@@ -964,9 +964,10 @@ class State extends Contract {
964
964
  await globalThis.transactionPoolStore.delete(hash);
965
965
  console.log('removing invalid transaction');
966
966
  if (isExecutionError(error)) {
967
- console.log('removing invalid block');
967
+ console.log(`removing invalid block ${block.index}`);
968
968
  await globalThis.blockStore.delete(await (await new BlockMessage(block)).hash());
969
- blocks.splice(block.index - 1, 1);
969
+ const deletedBlock = blocks.splice(block.index, 1);
970
+ console.log(`removed block ${deletedBlock[0].index}`);
970
971
  return this.#loadBlocks(blocks);
971
972
  }
972
973
  console.log(error);
@@ -1019,6 +1020,11 @@ class State extends Contract {
1019
1020
  const latest = await this.#getLatestBlock();
1020
1021
  return this.syncChain(latest);
1021
1022
  }
1023
+ async triggerLoad() {
1024
+ if (this.#blocks.length > 0) {
1025
+ this.#machine = await new Machine(this.#blocks);
1026
+ }
1027
+ }
1022
1028
  }
1023
1029
 
1024
1030
  globalThis.BigNumber = BigNumber;
@@ -37,5 +37,6 @@ export default class State extends Contract {
37
37
  get canSync(): boolean;
38
38
  get shouldSync(): boolean;
39
39
  triggerSync(): Promise<SyncState>;
40
+ triggerLoad(): Promise<void>;
40
41
  }
41
42
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leofcoin/chain",
3
- "version": "1.5.17",
3
+ "version": "1.5.19",
4
4
  "description": "Official javascript implementation",
5
5
  "exports": {
6
6
  "./node": {