@leofcoin/chain 1.7.3 → 1.7.5

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.
@@ -4418,7 +4418,7 @@ class State extends Contract {
4418
4418
  response: { blocks: this.#blocks.map((block) => block.hash) }
4419
4419
  });
4420
4420
  };
4421
- this.#loadBlockTransactions = (transactions) => Promise.all(transactions.map((transaction) => new TransactionMessage(transaction)));
4421
+ this.#loadBlockTransactions = (transactions) => Promise.all(transactions.map(async (transaction) => new TransactionMessage(await transactionStore.get(transaction))));
4422
4422
  this.#getLastTransactions = async () => {
4423
4423
  let lastTransactions = (await Promise.all((await this.blocks)
4424
4424
  // @ts-ignore
@@ -5075,9 +5075,7 @@ class Chain extends VersionControl {
5075
5075
  return Promise.all(transactionsToGet);
5076
5076
  }
5077
5077
  async #peerConnected(peerId) {
5078
- console.log({ connected: peerId });
5079
5078
  const peer = peernet.getConnection(peerId);
5080
- console.log({ peer });
5081
5079
  // todo handle version changes
5082
5080
  // for now just do nothing if version doesn't match
5083
5081
  debug(`peer connected with version ${peer.version}`);
@@ -5088,7 +5086,9 @@ class Chain extends VersionControl {
5088
5086
  return;
5089
5087
  const lastBlock = await this.#makeRequest(peer, 'lastBlock');
5090
5088
  const localBlock = await this.lastBlock;
5091
- const higherThenCurrentLocal = !localBlock.index ? true : lastBlock.index > localBlock.index;
5089
+ if (lastBlock.hash === '0x0')
5090
+ return;
5091
+ const higherThenCurrentLocal = !localBlock?.index ? true : lastBlock.index > localBlock.index;
5092
5092
  if (Object.keys(lastBlock).length > 0) {
5093
5093
  if (!this.lastBlock || higherThenCurrentLocal) {
5094
5094
  this.knownBlocks = await this.#makeRequest(peer, 'knownBlocks');
package/exports/chain.js CHANGED
@@ -785,7 +785,7 @@ class State extends Contract {
785
785
  response: { blocks: this.#blocks.map((block) => block.hash) }
786
786
  });
787
787
  };
788
- this.#loadBlockTransactions = (transactions) => Promise.all(transactions.map((transaction) => new TransactionMessage(transaction)));
788
+ this.#loadBlockTransactions = (transactions) => Promise.all(transactions.map(async (transaction) => new TransactionMessage(await transactionStore.get(transaction))));
789
789
  this.#getLastTransactions = async () => {
790
790
  let lastTransactions = (await Promise.all((await this.blocks)
791
791
  // @ts-ignore
@@ -1442,9 +1442,7 @@ class Chain extends VersionControl {
1442
1442
  return Promise.all(transactionsToGet);
1443
1443
  }
1444
1444
  async #peerConnected(peerId) {
1445
- console.log({ connected: peerId });
1446
1445
  const peer = peernet.getConnection(peerId);
1447
- console.log({ peer });
1448
1446
  // todo handle version changes
1449
1447
  // for now just do nothing if version doesn't match
1450
1448
  debug(`peer connected with version ${peer.version}`);
@@ -1455,7 +1453,9 @@ class Chain extends VersionControl {
1455
1453
  return;
1456
1454
  const lastBlock = await this.#makeRequest(peer, 'lastBlock');
1457
1455
  const localBlock = await this.lastBlock;
1458
- const higherThenCurrentLocal = !localBlock.index ? true : lastBlock.index > localBlock.index;
1456
+ if (lastBlock.hash === '0x0')
1457
+ return;
1458
+ const higherThenCurrentLocal = !localBlock?.index ? true : lastBlock.index > localBlock.index;
1459
1459
  if (Object.keys(lastBlock).length > 0) {
1460
1460
  if (!this.lastBlock || higherThenCurrentLocal) {
1461
1461
  this.knownBlocks = await this.#makeRequest(peer, 'knownBlocks');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leofcoin/chain",
3
- "version": "1.7.3",
3
+ "version": "1.7.5",
4
4
  "description": "Official javascript implementation",
5
5
  "private": false,
6
6
  "exports": {