@leofcoin/chain 1.7.135 → 1.7.136

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,11 +4754,8 @@ 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;
4760
4757
  return new globalThis.peernet.protos['peernet-response']({
4761
- response
4758
+ response: await this.lastBlock
4762
4759
  });
4763
4760
  };
4764
4761
  this.#knownBlocksHandler = async () => {
@@ -5128,6 +5125,7 @@ class State extends Contract {
5128
5125
  const task = async () => {
5129
5126
  try {
5130
5127
  const result = await peer.request(node.encode());
5128
+ debug$1({ result });
5131
5129
  return { result: Uint8Array.from(Object.values(result)), peer };
5132
5130
  }
5133
5131
  catch (error) {
@@ -5144,6 +5142,7 @@ class State extends Contract {
5144
5142
  promises = promises.sort((a, b) => b.index - a.index);
5145
5143
  if (promises.length > 0)
5146
5144
  latest = promises[0].value;
5145
+ debug$1(`Latest block from peers: ${latest.hash} @${latest.index}`);
5147
5146
  if (latest.hash && latest.hash !== '0x0') {
5148
5147
  let message = await globalThis.peernet.get(latest.hash, 'block');
5149
5148
  message = await new BlockMessage(message);
@@ -5259,7 +5258,7 @@ class State extends Contract {
5259
5258
  promiseRequests(promises) {
5260
5259
  return new Promise(async (resolve, reject) => {
5261
5260
  const timeout = setTimeout(() => {
5262
- resolve([]);
5261
+ resolve([{ index: 0, hash: '0x0' }]);
5263
5262
  debug$1('sync timed out');
5264
5263
  }, this.requestTimeout);
5265
5264
  promises = await Promise.allSettled(promises);
package/exports/chain.js CHANGED
@@ -881,11 +881,8 @@ 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;
887
884
  return new globalThis.peernet.protos['peernet-response']({
888
- response
885
+ response: await this.lastBlock
889
886
  });
890
887
  };
891
888
  this.#knownBlocksHandler = async () => {
@@ -1255,6 +1252,7 @@ class State extends Contract {
1255
1252
  const task = async () => {
1256
1253
  try {
1257
1254
  const result = await peer.request(node.encode());
1255
+ debug$1({ result });
1258
1256
  return { result: Uint8Array.from(Object.values(result)), peer };
1259
1257
  }
1260
1258
  catch (error) {
@@ -1271,6 +1269,7 @@ class State extends Contract {
1271
1269
  promises = promises.sort((a, b) => b.index - a.index);
1272
1270
  if (promises.length > 0)
1273
1271
  latest = promises[0].value;
1272
+ debug$1(`Latest block from peers: ${latest.hash} @${latest.index}`);
1274
1273
  if (latest.hash && latest.hash !== '0x0') {
1275
1274
  let message = await globalThis.peernet.get(latest.hash, 'block');
1276
1275
  message = await new BlockMessage(message);
@@ -1386,7 +1385,7 @@ class State extends Contract {
1386
1385
  promiseRequests(promises) {
1387
1386
  return new Promise(async (resolve, reject) => {
1388
1387
  const timeout = setTimeout(() => {
1389
- resolve([]);
1388
+ resolve([{ index: 0, hash: '0x0' }]);
1390
1389
  debug$1('sync timed out');
1391
1390
  }, this.requestTimeout);
1392
1391
  promises = await Promise.allSettled(promises);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leofcoin/chain",
3
- "version": "1.7.135",
3
+ "version": "1.7.136",
4
4
  "description": "Official javascript implementation",
5
5
  "private": false,
6
6
  "exports": {