@leofcoin/chain 1.7.146 → 1.7.147

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.
@@ -4880,6 +4880,7 @@ class State extends Contract {
4880
4880
  localHash = await globalThis.stateStore.get('lastBlock');
4881
4881
  }
4882
4882
  catch (error) {
4883
+ globalThis.stateStore.put('lastBlock', new TextEncoder().encode('0x0'));
4883
4884
  debug$1('no local state found');
4884
4885
  }
4885
4886
  debug$1(`resolving block: ${hash} @${index !== undefined ? index : 'unknown'}`);
@@ -5903,12 +5904,10 @@ class Chain extends VersionControl {
5903
5904
  if (lastBlock.hash === '0x0')
5904
5905
  return;
5905
5906
  const higherThenCurrentLocal = !localBlock?.index ? true : lastBlock.index > localBlock.index;
5906
- if (Object.keys(lastBlock).length > 0) {
5907
+ if (lastBlock) {
5907
5908
  if (!this.lastBlock || higherThenCurrentLocal) {
5908
5909
  this.knownBlocks = await this.#makeRequest(peer, 'knownBlocks');
5909
- await this.#makeRequest(peer, 'stateInfo');
5910
- await this.syncChain(lastBlock);
5911
- // this.machine.states.info = stateInfo
5910
+ this.wantList.push(...this.knownBlocks);
5912
5911
  }
5913
5912
  }
5914
5913
  if (this.wantList.length > 0) {
@@ -5927,6 +5926,9 @@ class Chain extends VersionControl {
5927
5926
  if (this.#participating && peerTransactionPool.length > 0)
5928
5927
  return this.#runEpoch();
5929
5928
  }, 3000);
5929
+ const stateInfo = await this.#makeRequest(peer, 'stateInfo');
5930
+ await this.syncChain(lastBlock);
5931
+ this.machine.states.info = stateInfo;
5930
5932
  }
5931
5933
  #epochTimeout;
5932
5934
  async #transactionPoolHandler() {
package/exports/chain.js CHANGED
@@ -1020,6 +1020,7 @@ class State extends Contract {
1020
1020
  localHash = await globalThis.stateStore.get('lastBlock');
1021
1021
  }
1022
1022
  catch (error) {
1023
+ globalThis.stateStore.put('lastBlock', new TextEncoder().encode('0x0'));
1023
1024
  debug$1('no local state found');
1024
1025
  }
1025
1026
  debug$1(`resolving block: ${hash} @${index !== undefined ? index : 'unknown'}`);
@@ -2043,12 +2044,10 @@ class Chain extends VersionControl {
2043
2044
  if (lastBlock.hash === '0x0')
2044
2045
  return;
2045
2046
  const higherThenCurrentLocal = !localBlock?.index ? true : lastBlock.index > localBlock.index;
2046
- if (Object.keys(lastBlock).length > 0) {
2047
+ if (lastBlock) {
2047
2048
  if (!this.lastBlock || higherThenCurrentLocal) {
2048
2049
  this.knownBlocks = await this.#makeRequest(peer, 'knownBlocks');
2049
- await this.#makeRequest(peer, 'stateInfo');
2050
- await this.syncChain(lastBlock);
2051
- // this.machine.states.info = stateInfo
2050
+ this.wantList.push(...this.knownBlocks);
2052
2051
  }
2053
2052
  }
2054
2053
  if (this.wantList.length > 0) {
@@ -2067,6 +2066,9 @@ class Chain extends VersionControl {
2067
2066
  if (this.#participating && peerTransactionPool.length > 0)
2068
2067
  return this.#runEpoch();
2069
2068
  }, 3000);
2069
+ const stateInfo = await this.#makeRequest(peer, 'stateInfo');
2070
+ await this.syncChain(lastBlock);
2071
+ this.machine.states.info = stateInfo;
2070
2072
  }
2071
2073
  #epochTimeout;
2072
2074
  async #transactionPoolHandler() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leofcoin/chain",
3
- "version": "1.7.146",
3
+ "version": "1.7.147",
4
4
  "description": "Official javascript implementation",
5
5
  "private": false,
6
6
  "exports": {