@leofcoin/workers 1.5.23 → 1.5.24
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,24 @@ const _ = {
|
|
|
488
488
|
worker.postMessage({ type: 'machine-ready', lastBlock });
|
|
489
489
|
},
|
|
490
490
|
addLoadedBlock: (block) => {
|
|
491
|
-
|
|
491
|
+
const size = formatBytes(JSON.stringify(block).length);
|
|
492
|
+
block = JSON.parse(block, jsonParseBigInt);
|
|
493
|
+
worker.postMessage({
|
|
494
|
+
type: 'debug',
|
|
495
|
+
message: `addLoadedBlock: ${block.index} @${block.hash} size: ${size}`
|
|
496
|
+
});
|
|
497
|
+
// if (block.decoded) block = { ...block.decoded, hash: await new BlockMessage(block).hash() }
|
|
498
|
+
// if (blocks[block.index - 1]) {
|
|
499
|
+
// console.warn(`block ${block.index} already loaded, skipping`)
|
|
500
|
+
// return false
|
|
501
|
+
// }
|
|
502
|
+
blocks[Number(block.index) - 1] = block;
|
|
492
503
|
lastBlock = blocks[blocks.length - 1];
|
|
493
504
|
totalBlocks = totalBlocks += 1n;
|
|
505
|
+
worker.postMessage({
|
|
506
|
+
type: 'debug',
|
|
507
|
+
message: `added block: ${block.index} @${block.hash} size: ${formatBytes(JSON.stringify(block).length)}`
|
|
508
|
+
});
|
|
494
509
|
return true;
|
|
495
510
|
},
|
|
496
511
|
loadBlock: (block) => {
|
|
@@ -488,9 +488,24 @@ const _ = {
|
|
|
488
488
|
worker.postMessage({ type: 'machine-ready', lastBlock });
|
|
489
489
|
},
|
|
490
490
|
addLoadedBlock: (block) => {
|
|
491
|
-
|
|
491
|
+
const size = formatBytes(JSON.stringify(block).length);
|
|
492
|
+
block = JSON.parse(block, jsonParseBigInt);
|
|
493
|
+
worker.postMessage({
|
|
494
|
+
type: 'debug',
|
|
495
|
+
message: `addLoadedBlock: ${block.index} @${block.hash} size: ${size}`
|
|
496
|
+
});
|
|
497
|
+
// if (block.decoded) block = { ...block.decoded, hash: await new BlockMessage(block).hash() }
|
|
498
|
+
// if (blocks[block.index - 1]) {
|
|
499
|
+
// console.warn(`block ${block.index} already loaded, skipping`)
|
|
500
|
+
// return false
|
|
501
|
+
// }
|
|
502
|
+
blocks[Number(block.index) - 1] = block;
|
|
492
503
|
lastBlock = blocks[blocks.length - 1];
|
|
493
504
|
totalBlocks = totalBlocks += 1n;
|
|
505
|
+
worker.postMessage({
|
|
506
|
+
type: 'debug',
|
|
507
|
+
message: `added block: ${block.index} @${block.hash} size: ${formatBytes(JSON.stringify(block).length)}`
|
|
508
|
+
});
|
|
494
509
|
return true;
|
|
495
510
|
},
|
|
496
511
|
loadBlock: (block) => {
|