@leofcoin/chain 1.7.136 → 1.7.137

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.
@@ -4754,8 +4754,11 @@ class State extends Contract {
4754
4754
  });
4755
4755
  };
4756
4756
  this.#lastBlockHandler = async () => {
4757
+ const lastBlock = await this.lastBlock;
4758
+ // Don't advertise 0x0 as a valid block to other peers
4759
+ const response = lastBlock.hash !== '0x0' ? lastBlock : undefined;
4757
4760
  return new globalThis.peernet.protos['peernet-response']({
4758
- response: await this.lastBlock
4761
+ response
4759
4762
  });
4760
4763
  };
4761
4764
  this.#knownBlocksHandler = async () => {
@@ -5889,7 +5892,9 @@ class Chain extends VersionControl {
5889
5892
  return Promise.all(transactionsToGet);
5890
5893
  }
5891
5894
  async #peerConnected(peerId) {
5895
+ debug(`peer connected: ${peerId}`);
5892
5896
  const peer = peernet.getConnection(peerId);
5897
+ debug(`peer connected with version ${peer.version}`);
5893
5898
  // todo handle version changes
5894
5899
  // for now just do nothing if version doesn't match
5895
5900
  debug(`peer connected with version ${peer.version}`);
package/exports/chain.js CHANGED
@@ -881,8 +881,11 @@ class State extends Contract {
881
881
  });
882
882
  };
883
883
  this.#lastBlockHandler = async () => {
884
+ const lastBlock = await this.lastBlock;
885
+ // Don't advertise 0x0 as a valid block to other peers
886
+ const response = lastBlock.hash !== '0x0' ? lastBlock : undefined;
884
887
  return new globalThis.peernet.protos['peernet-response']({
885
- response: await this.lastBlock
888
+ response
886
889
  });
887
890
  };
888
891
  this.#knownBlocksHandler = async () => {
@@ -2016,7 +2019,9 @@ class Chain extends VersionControl {
2016
2019
  return Promise.all(transactionsToGet);
2017
2020
  }
2018
2021
  async #peerConnected(peerId) {
2022
+ debug(`peer connected: ${peerId}`);
2019
2023
  const peer = peernet.getConnection(peerId);
2024
+ debug(`peer connected with version ${peer.version}`);
2020
2025
  // todo handle version changes
2021
2026
  // for now just do nothing if version doesn't match
2022
2027
  debug(`peer connected with version ${peer.version}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leofcoin/chain",
3
- "version": "1.7.136",
3
+ "version": "1.7.137",
4
4
  "description": "Official javascript implementation",
5
5
  "private": false,
6
6
  "exports": {