@leofcoin/workers 1.5.24 → 1.5.26

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