@leofcoin/chain 1.5.16 → 1.5.18
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.
- package/LICENSE +88 -88
- package/README.md +4 -4
- package/exports/browser/chain.js +21 -21
- package/exports/browser/{index-329e0324-0b2da3d5.js → index-329e0324-e2a4f639.js} +2 -2
- package/exports/browser/{index-e8f03811.js → index-5e385ee1.js} +9 -8
- package/exports/browser/{messages-000b7f84-854cd18c.js → messages-000b7f84-ef0adf20.js} +2 -2
- package/exports/browser/{node-browser-f07d5ecd.js → node-browser-01f26631.js} +3 -3
- package/exports/browser/node-browser.js +2 -2
- package/exports/browser/workers/block-worker.js +33 -32
- package/exports/browser/workers/machine-worker.js +243 -242
- package/exports/chain.js +3 -3
- package/exports/workers/block-worker.js +33 -32
- package/exports/workers/machine-worker.js +243 -242
- package/package.json +105 -105
|
@@ -5931,21 +5931,21 @@ class BlockMessage extends FormatInterface {
|
|
|
5931
5931
|
const name = 'block-message';
|
|
5932
5932
|
super(buffer, proto, { name });
|
|
5933
5933
|
}
|
|
5934
|
-
encode() {
|
|
5935
|
-
|
|
5934
|
+
encode(decoded) {
|
|
5935
|
+
decoded = decoded || this.decoded;
|
|
5936
5936
|
const validators = [];
|
|
5937
5937
|
const transactions = [];
|
|
5938
5938
|
for (const validator of decoded.validators) {
|
|
5939
5939
|
if (validator instanceof ValidatorMessage)
|
|
5940
|
-
validators.push(validator.
|
|
5940
|
+
validators.push(validator.encode());
|
|
5941
5941
|
else
|
|
5942
|
-
validators.push(new ValidatorMessage(validator).
|
|
5942
|
+
validators.push(new ValidatorMessage(validator).encode());
|
|
5943
5943
|
}
|
|
5944
5944
|
for (const transaction of decoded.transactions) {
|
|
5945
5945
|
if (transaction instanceof TransactionMessage)
|
|
5946
|
-
transactions.push(transaction.
|
|
5946
|
+
transactions.push(transaction.encode());
|
|
5947
5947
|
else
|
|
5948
|
-
transactions.push(new TransactionMessage(transaction).
|
|
5948
|
+
transactions.push(new TransactionMessage(transaction).encode());
|
|
5949
5949
|
}
|
|
5950
5950
|
return super.encode({
|
|
5951
5951
|
...decoded,
|
|
@@ -5953,8 +5953,9 @@ class BlockMessage extends FormatInterface {
|
|
|
5953
5953
|
transactions: index$5(transactions)
|
|
5954
5954
|
});
|
|
5955
5955
|
}
|
|
5956
|
-
decode() {
|
|
5957
|
-
|
|
5956
|
+
decode(encoded) {
|
|
5957
|
+
encoded = encoded || this.encoded;
|
|
5958
|
+
super.decode(encoded);
|
|
5958
5959
|
// @ts-ignore
|
|
5959
5960
|
this.decoded.transactions = index$4(this.decoded.transactions).map(transaction => new TransactionMessage(transaction).decoded);
|
|
5960
5961
|
// @ts-ignore
|
|
@@ -6056,28 +6057,28 @@ class EasyWorker {
|
|
|
6056
6057
|
}
|
|
6057
6058
|
}
|
|
6058
6059
|
|
|
6059
|
-
const worker = new EasyWorker();
|
|
6060
|
-
|
|
6061
|
-
globalThis.BigNumber = BigNumber;
|
|
6062
|
-
globalThis.contracts = {};
|
|
6063
|
-
|
|
6064
|
-
const run = async (blocks) => {
|
|
6065
|
-
blocks = await Promise.all(blocks.map(block => new BlockMessage(block)));
|
|
6066
|
-
blocks = blocks.sort((a, b) => a.decoded.timestamp - b.decoded.timestamp);
|
|
6067
|
-
|
|
6068
|
-
blocks = await Promise.all(blocks.map(block => new Promise(async (resolve, reject) => {
|
|
6069
|
-
// todo: tx worker or nah?
|
|
6070
|
-
const size = block.encoded.length || block.encoded.byteLength;
|
|
6071
|
-
console.log(`loaded block: ${await block.hash()} @${block.decoded.index} ${formatBytes(size)}`);
|
|
6072
|
-
resolve(block);
|
|
6073
|
-
})));
|
|
6074
|
-
return blocks
|
|
6075
|
-
};
|
|
6076
|
-
|
|
6077
|
-
const tasks = async blocks => {
|
|
6078
|
-
blocks = await run(blocks);
|
|
6079
|
-
worker.postMessage(blocks);
|
|
6080
|
-
};
|
|
6081
|
-
|
|
6082
|
-
|
|
6060
|
+
const worker = new EasyWorker();
|
|
6061
|
+
|
|
6062
|
+
globalThis.BigNumber = BigNumber;
|
|
6063
|
+
globalThis.contracts = {};
|
|
6064
|
+
|
|
6065
|
+
const run = async (blocks) => {
|
|
6066
|
+
blocks = await Promise.all(blocks.map(block => new BlockMessage(block)));
|
|
6067
|
+
blocks = blocks.sort((a, b) => a.decoded.timestamp - b.decoded.timestamp);
|
|
6068
|
+
|
|
6069
|
+
blocks = await Promise.all(blocks.map(block => new Promise(async (resolve, reject) => {
|
|
6070
|
+
// todo: tx worker or nah?
|
|
6071
|
+
const size = block.encoded.length || block.encoded.byteLength;
|
|
6072
|
+
console.log(`loaded block: ${await block.hash()} @${block.decoded.index} ${formatBytes(size)}`);
|
|
6073
|
+
resolve(block);
|
|
6074
|
+
})));
|
|
6075
|
+
return blocks
|
|
6076
|
+
};
|
|
6077
|
+
|
|
6078
|
+
const tasks = async blocks => {
|
|
6079
|
+
blocks = await run(blocks);
|
|
6080
|
+
worker.postMessage(blocks);
|
|
6081
|
+
};
|
|
6082
|
+
|
|
6083
|
+
|
|
6083
6084
|
worker.onmessage(data => tasks(data));
|