@leofcoin/chain 1.7.31 → 1.7.33

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.
@@ -4371,6 +4371,9 @@ class Chain extends VersionControl {
4371
4371
  // })
4372
4372
  await globalThis.peernet.addRequestHandler('transactionPool', this.#transactionPoolHandler.bind(this));
4373
4373
  await globalThis.peernet.addRequestHandler('version', this.#versionHandler.bind(this));
4374
+ await globalThis.peernet.addRequestHandler('stateInfo', () => {
4375
+ return new globalThis.peernet.protos['peernet-response']({ response: this.machine.states.info });
4376
+ });
4374
4377
  globalThis.peernet.subscribe('add-block', this.#addBlock.bind(this));
4375
4378
  globalThis.peernet.subscribe('invalid-transaction', this.#invalidTransaction.bind(this));
4376
4379
  globalThis.peernet.subscribe('send-transaction', this.#sendTransaction.bind(this));
@@ -4431,10 +4434,10 @@ class Chain extends VersionControl {
4431
4434
  if (Object.keys(lastBlock).length > 0) {
4432
4435
  if (!this.lastBlock || higherThenCurrentLocal) {
4433
4436
  this.knownBlocks = await this.#makeRequest(peer, 'knownBlocks');
4437
+ const stateinfo = await this.#makeRequest(peer, 'stateInfo');
4434
4438
  await this.syncChain(lastBlock);
4439
+ this.#state.info = stateinfo;
4435
4440
  }
4436
- else if (!this.knownBlocks)
4437
- this.knownBlocks = await this.#makeRequest(peer, 'knownBlocks');
4438
4441
  }
4439
4442
  if (this.wantList.length > 0) {
4440
4443
  const promises = await Promise.allSettled(this.wantList.map((hash) => peernet.get(hash)));
package/exports/chain.js CHANGED
@@ -1472,6 +1472,9 @@ class Chain extends VersionControl {
1472
1472
  // })
1473
1473
  await globalThis.peernet.addRequestHandler('transactionPool', this.#transactionPoolHandler.bind(this));
1474
1474
  await globalThis.peernet.addRequestHandler('version', this.#versionHandler.bind(this));
1475
+ await globalThis.peernet.addRequestHandler('stateInfo', () => {
1476
+ return new globalThis.peernet.protos['peernet-response']({ response: this.machine.states.info });
1477
+ });
1475
1478
  globalThis.peernet.subscribe('add-block', this.#addBlock.bind(this));
1476
1479
  globalThis.peernet.subscribe('invalid-transaction', this.#invalidTransaction.bind(this));
1477
1480
  globalThis.peernet.subscribe('send-transaction', this.#sendTransaction.bind(this));
@@ -1532,10 +1535,10 @@ class Chain extends VersionControl {
1532
1535
  if (Object.keys(lastBlock).length > 0) {
1533
1536
  if (!this.lastBlock || higherThenCurrentLocal) {
1534
1537
  this.knownBlocks = await this.#makeRequest(peer, 'knownBlocks');
1538
+ const stateinfo = await this.#makeRequest(peer, 'stateInfo');
1535
1539
  await this.syncChain(lastBlock);
1540
+ this.#state.info = stateinfo;
1536
1541
  }
1537
- else if (!this.knownBlocks)
1538
- this.knownBlocks = await this.#makeRequest(peer, 'knownBlocks');
1539
1542
  }
1540
1543
  if (this.wantList.length > 0) {
1541
1544
  const promises = await Promise.allSettled(this.wantList.map((hash) => peernet.get(hash)));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leofcoin/chain",
3
- "version": "1.7.31",
3
+ "version": "1.7.33",
4
4
  "description": "Official javascript implementation",
5
5
  "private": false,
6
6
  "exports": {