@leofcoin/workers 1.5.23 → 1.5.25

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,9 +488,20 @@ const _ = {
488
488
  worker.postMessage({ type: 'machine-ready', lastBlock });
489
489
  },
490
490
  addLoadedBlock: (block) => {
491
- blocks[block.index - 1] = block;
491
+ const size = formatBytes(block.length);
492
+ block = JSON.parse(block, jsonParseBigInt);
493
+ // if (block.decoded) block = { ...block.decoded, hash: await new BlockMessage(block).hash() }
494
+ // if (blocks[block.index - 1]) {
495
+ // console.warn(`block ${block.index} already loaded, skipping`)
496
+ // return false
497
+ // }
498
+ blocks[block.index.toString()] = block;
492
499
  lastBlock = blocks[blocks.length - 1];
493
- totalBlocks = totalBlocks += 1n;
500
+ totalBlocks += 1n;
501
+ worker.postMessage({
502
+ type: 'debug',
503
+ message: `added block: ${block.hash}@${block.index} size: ${size}`
504
+ });
494
505
  return true;
495
506
  },
496
507
  loadBlock: (block) => {
@@ -488,9 +488,20 @@ const _ = {
488
488
  worker.postMessage({ type: 'machine-ready', lastBlock });
489
489
  },
490
490
  addLoadedBlock: (block) => {
491
- blocks[block.index - 1] = block;
491
+ const size = formatBytes(block.length);
492
+ block = JSON.parse(block, jsonParseBigInt);
493
+ // if (block.decoded) block = { ...block.decoded, hash: await new BlockMessage(block).hash() }
494
+ // if (blocks[block.index - 1]) {
495
+ // console.warn(`block ${block.index} already loaded, skipping`)
496
+ // return false
497
+ // }
498
+ blocks[block.index.toString()] = block;
492
499
  lastBlock = blocks[blocks.length - 1];
493
- totalBlocks = totalBlocks += 1n;
500
+ totalBlocks += 1n;
501
+ worker.postMessage({
502
+ type: 'debug',
503
+ message: `added block: ${block.hash}@${block.index} size: ${size}`
504
+ });
494
505
  return true;
495
506
  },
496
507
  loadBlock: (block) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leofcoin/workers",
3
- "version": "1.5.23",
3
+ "version": "1.5.25",
4
4
  "description": "Workers used in @leofcoin/chain",
5
5
  "type": "module",
6
6
  "private": false,