@leofcoin/chain 1.7.130 → 1.7.131

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.
@@ -4886,13 +4886,19 @@ class State extends Contract {
4886
4886
  }
4887
4887
  async #resolveBlock(hash) {
4888
4888
  let index = this.#blockHashMap.get(hash);
4889
+ let localHash = '0x0';
4890
+ try {
4891
+ localHash = await globalThis.stateStore.get('lastBlock');
4892
+ }
4893
+ catch (error) {
4894
+ debug$1('no local state found');
4895
+ }
4889
4896
  if (this.#blocks[index]) {
4890
4897
  // Block already exists, check if we need to resolve previous blocks
4891
- const localHash = await globalThis.stateStore.get('lastBlock');
4892
4898
  const previousHash = this.#blocks[index].previousHash;
4893
4899
  if (previousHash === localHash)
4894
4900
  return;
4895
- if (previousHash !== '0x0' && !this.#blocks[this.#blockHashMap.get(previousHash)]) {
4901
+ if (previousHash !== '0x0') {
4896
4902
  // Previous block not in memory, recursively resolve it
4897
4903
  return this.resolveBlock(previousHash);
4898
4904
  }
package/exports/chain.js CHANGED
@@ -1013,13 +1013,19 @@ class State extends Contract {
1013
1013
  }
1014
1014
  async #resolveBlock(hash) {
1015
1015
  let index = this.#blockHashMap.get(hash);
1016
+ let localHash = '0x0';
1017
+ try {
1018
+ localHash = await globalThis.stateStore.get('lastBlock');
1019
+ }
1020
+ catch (error) {
1021
+ debug$1('no local state found');
1022
+ }
1016
1023
  if (this.#blocks[index]) {
1017
1024
  // Block already exists, check if we need to resolve previous blocks
1018
- const localHash = await globalThis.stateStore.get('lastBlock');
1019
1025
  const previousHash = this.#blocks[index].previousHash;
1020
1026
  if (previousHash === localHash)
1021
1027
  return;
1022
- if (previousHash !== '0x0' && !this.#blocks[this.#blockHashMap.get(previousHash)]) {
1028
+ if (previousHash !== '0x0') {
1023
1029
  // Previous block not in memory, recursively resolve it
1024
1030
  return this.resolveBlock(previousHash);
1025
1031
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leofcoin/chain",
3
- "version": "1.7.130",
3
+ "version": "1.7.131",
4
4
  "description": "Official javascript implementation",
5
5
  "private": false,
6
6
  "exports": {