@leofcoin/chain 1.7.86 → 1.7.87

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.
@@ -488,19 +488,19 @@ const _ = {
488
488
  worker.postMessage({ type: 'machine-ready', lastBlock });
489
489
  },
490
490
  addLoadedBlock: (block) => {
491
- formatBytes(JSON.stringify(block).length);
491
+ const size = formatBytes(block.length);
492
492
  block = JSON.parse(block, jsonParseBigInt);
493
493
  // if (block.decoded) block = { ...block.decoded, hash: await new BlockMessage(block).hash() }
494
494
  // if (blocks[block.index - 1]) {
495
495
  // console.warn(`block ${block.index} already loaded, skipping`)
496
496
  // return false
497
497
  // }
498
- blocks[Number(block.index) - 1] = block;
498
+ blocks[block.index.toString()] = block;
499
499
  lastBlock = blocks[blocks.length - 1];
500
- totalBlocks = totalBlocks += 1n;
500
+ totalBlocks += 1n;
501
501
  worker.postMessage({
502
502
  type: 'debug',
503
- message: `added block: ${block.index} @${block.hash} size: ${formatBytes(JSON.stringify(block).length)}`
503
+ message: `added block: ${block.hash}@${block.index} size: ${size}`
504
504
  });
505
505
  return true;
506
506
  },
@@ -488,19 +488,19 @@ const _ = {
488
488
  worker.postMessage({ type: 'machine-ready', lastBlock });
489
489
  },
490
490
  addLoadedBlock: (block) => {
491
- formatBytes(JSON.stringify(block).length);
491
+ const size = formatBytes(block.length);
492
492
  block = JSON.parse(block, jsonParseBigInt);
493
493
  // if (block.decoded) block = { ...block.decoded, hash: await new BlockMessage(block).hash() }
494
494
  // if (blocks[block.index - 1]) {
495
495
  // console.warn(`block ${block.index} already loaded, skipping`)
496
496
  // return false
497
497
  // }
498
- blocks[Number(block.index) - 1] = block;
498
+ blocks[block.index.toString()] = block;
499
499
  lastBlock = blocks[blocks.length - 1];
500
- totalBlocks = totalBlocks += 1n;
500
+ totalBlocks += 1n;
501
501
  worker.postMessage({
502
502
  type: 'debug',
503
- message: `added block: ${block.index} @${block.hash} size: ${formatBytes(JSON.stringify(block).length)}`
503
+ message: `added block: ${block.hash}@${block.index} size: ${size}`
504
504
  });
505
505
  return true;
506
506
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leofcoin/chain",
3
- "version": "1.7.86",
3
+ "version": "1.7.87",
4
4
  "description": "Official javascript implementation",
5
5
  "private": false,
6
6
  "exports": {
@@ -72,7 +72,7 @@
72
72
  "@leofcoin/peernet": "^1.1.92",
73
73
  "@leofcoin/storage": "^3.5.38",
74
74
  "@leofcoin/utils": "^1.1.39",
75
- "@leofcoin/workers": "^1.5.23",
75
+ "@leofcoin/workers": "^1.5.24",
76
76
  "@vandeurenglenn/base58": "^1.1.9",
77
77
  "@vandeurenglenn/easy-worker": "^1.0.2",
78
78
  "semver": "^7.7.2"