@leofcoin/chain 1.5.12 → 1.5.14

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.
@@ -1499,7 +1499,7 @@ class State extends Contract {
1499
1499
  if (lastTransactions.includes(hash)) {
1500
1500
  console.log('removing invalid block');
1501
1501
  await globalThis.blockStore.delete(await (await new BlockMessage(block)).hash());
1502
- blocks.splice(block.index - 1);
1502
+ blocks.splice(block.index);
1503
1503
  return this.#loadBlocks(blocks);
1504
1504
  }
1505
1505
  try {
package/exports/chain.js CHANGED
@@ -942,7 +942,7 @@ class State extends Contract {
942
942
  if (lastTransactions.includes(hash)) {
943
943
  console.log('removing invalid block');
944
944
  await globalThis.blockStore.delete(await (await new BlockMessage(block)).hash());
945
- blocks.splice(block.index - 1);
945
+ blocks.splice(block.index);
946
946
  return this.#loadBlocks(blocks);
947
947
  }
948
948
  try {
package/exports/node.js CHANGED
@@ -18,10 +18,12 @@ class Node {
18
18
  }, password) {
19
19
  this.#node = globalThis.Peernet ? await new globalThis.Peernet(config, password) : await new Peernet(config, password);
20
20
  await nodeConfig(config);
21
- globalThis.pubsub.subscribe('chain:ready', () => {
21
+ globalThis.pubsub.subscribe('chain:ready', async () => {
22
22
  // when autostart is false the node will only be started after the chain is ready (this is here so we can just use node for communication)
23
- if (!this.#node.autoStart)
24
- this.#node.start();
23
+ if (!this.#node.autoStart) {
24
+ await this.#node.start();
25
+ pubsub.publish('node:ready', true);
26
+ }
25
27
  });
26
28
  return this;
27
29
  // this.config = await config()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leofcoin/chain",
3
- "version": "1.5.12",
3
+ "version": "1.5.14",
4
4
  "description": "Official javascript implementation",
5
5
  "exports": {
6
6
  "./node": {