@leofcoin/chain 1.5.63 → 1.5.65
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/exports/browser/{_polyfill-node.child_process-JsWeMPst.js → _polyfill-node.child_process-rc1HO9Xs.js} +46 -47
- package/exports/browser/{_polyfill-node.url-0PWARF9f.js → _polyfill-node.url-1q06MepH.js} +1 -1
- package/exports/browser/{browser-dc41c03f-8RoAu8QY.js → browser-1GyRaZxg-C9SpI6hG.js} +2 -2
- package/exports/browser/chain.js +102 -61
- package/exports/browser/{client-f193279c-xoTAp1Bg.js → client-UOCjJBGl-pbv-pTHd.js} +18 -14
- package/exports/browser/{index-fd97ecae-DMIypRPM.js → index-K4Kwju30-vS3fNpxy.js} +2 -2
- package/exports/browser/{index-81687e93-rKzKdyEa.js → index-ub31QSed-EMPr2oeb.js} +2 -2
- package/exports/browser/{messages-cccb78db-bQaa1gST.js → messages-guyZfse6-JeAlT5Nb.js} +2 -2
- package/exports/browser/{node-browser-cqEqYlW7.js → node-browser-0Ly80awM.js} +625 -609
- package/exports/browser/node-browser.js +2 -2
- package/exports/browser/workers/block-worker.js +1 -4
- package/exports/browser/workers/machine-worker.js +57 -35
- package/exports/browser/workers/{worker-Suy0gj0S.js → worker-hbo9s9AT.js} +47 -59
- package/exports/chain.d.ts +1 -0
- package/exports/chain.js +66 -51
- package/exports/workers/block-worker.js +1 -4
- package/exports/workers/machine-worker.js +57 -35
- package/exports/workers/{worker-Suy0gj0S.js → worker-hbo9s9AT.js} +47 -59
- package/package.json +4 -3
- /package/exports/browser/{browser-2c73e2ef-AyxSBUXj.js → browser-AyxSBUXj-AyxSBUXj.js} +0 -0
- /package/exports/browser/{qr-scanner-worker.min-c002e984-RaSiJc_R.js → qr-scanner-worker.min-RaSiJc_R-RaSiJc_R.js} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { N as default } from './node-browser-
|
|
2
|
-
import './_polyfill-node.child_process-
|
|
1
|
+
export { N as default } from './node-browser-0Ly80awM.js';
|
|
2
|
+
import './_polyfill-node.child_process-rc1HO9Xs.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { E as EasyWorker, B as BigNumber, a as BlockMessage
|
|
1
|
+
import { E as EasyWorker, B as BigNumber, a as BlockMessage } from './worker-hbo9s9AT.js';
|
|
2
2
|
|
|
3
3
|
const worker = new EasyWorker();
|
|
4
4
|
|
|
@@ -18,9 +18,6 @@ const run = async (blocks) => {
|
|
|
18
18
|
const size = block.encoded.length || block.encoded.byteLength;
|
|
19
19
|
const hash = await block.hash();
|
|
20
20
|
const index = block.decoded.index;
|
|
21
|
-
console.log(`loaded block: ${hash} @${index} ${formatBytes(size)}`);
|
|
22
|
-
// todo we don't want this, need shared state
|
|
23
|
-
block.decoded.transactions = block.decoded.transactions.sort((a, b) => a.nonce - b.nonce);
|
|
24
21
|
resolve({ ...block.decoded, hash, blockInfo: { hash, size, index } });
|
|
25
22
|
})
|
|
26
23
|
)
|
|
@@ -1,4 +1,15 @@
|
|
|
1
|
-
import { E as EasyWorker, B as BigNumber,
|
|
1
|
+
import { E as EasyWorker, B as BigNumber, C as ContractMessage, T as TransactionMessage } from './worker-hbo9s9AT.js';
|
|
2
|
+
|
|
3
|
+
const byteFormats = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
|
4
|
+
const formatBytes = (bytes, decimals = 2) => {
|
|
5
|
+
if (bytes === 0)
|
|
6
|
+
return '0 Bytes';
|
|
7
|
+
if (decimals < 0)
|
|
8
|
+
decimals = 0;
|
|
9
|
+
const k = 1024;
|
|
10
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
11
|
+
return `${parseFloat((bytes / Math.pow(k, i)).toFixed(decimals))} ${byteFormats[i]}`;
|
|
12
|
+
};
|
|
2
13
|
|
|
3
14
|
var contractFactory = "237,198,141,3,53,89,84,113,122,116,99,109,98,57,68,110,99,114,50,116,116,57,77,100,50,104,77,84,106,107,102,72,56,50,68,57,116,118,119,76,106,76,55,78,98,117,67,118,72,111,100,51,114,98,115,70,71,117,173,5,99,108,97,115,115,32,70,97,99,116,111,114,121,123,35,110,97,109,101,61,34,65,114,116,79,110,108,105,110,101,67,111,110,116,114,97,99,116,70,97,99,116,111,114,121,34,59,35,116,111,116,97,108,67,111,110,116,114,97,99,116,115,61,48,59,35,99,111,110,116,114,97,99,116,115,61,91,93,59,99,111,110,115,116,114,117,99,116,111,114,40,115,116,97,116,101,41,123,115,116,97,116,101,38,38,40,116,104,105,115,46,35,99,111,110,116,114,97,99,116,115,61,115,116,97,116,101,46,99,111,110,116,114,97,99,116,115,44,116,104,105,115,46,35,116,111,116,97,108,67,111,110,116,114,97,99,116,115,61,115,116,97,116,101,46,116,111,116,97,108,67,111,110,116,114,97,99,116,115,41,125,103,101,116,32,115,116,97,116,101,40,41,123,114,101,116,117,114,110,123,116,111,116,97,108,67,111,110,116,114,97,99,116,115,58,116,104,105,115,46,35,116,111,116,97,108,67,111,110,116,114,97,99,116,115,44,99,111,110,116,114,97,99,116,115,58,116,104,105,115,46,35,99,111,110,116,114,97,99,116,115,125,125,103,101,116,32,110,97,109,101,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,110,97,109,101,125,103,101,116,32,99,111,110,116,114,97,99,116,115,40,41,123,114,101,116,117,114,110,91,46,46,46,116,104,105,115,46,35,99,111,110,116,114,97,99,116,115,93,125,103,101,116,32,116,111,116,97,108,67,111,110,116,114,97,99,116,115,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,116,111,116,97,108,67,111,110,116,114,97,99,116,115,125,105,115,82,101,103,105,115,116,101,114,101,100,40,97,100,100,114,101,115,115,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,99,111,110,116,114,97,99,116,115,46,105,110,99,108,117,100,101,115,40,97,100,100,114,101,115,115,41,125,97,115,121,110,99,32,114,101,103,105,115,116,101,114,67,111,110,116,114,97,99,116,40,97,100,100,114,101,115,115,41,123,105,102,40,97,119,97,105,116,32,109,115,103,46,115,116,97,116,105,99,67,97,108,108,40,97,100,100,114,101,115,115,44,34,104,97,115,82,111,108,101,34,44,91,109,115,103,46,115,101,110,100,101,114,44,34,79,87,78,69,82,34,93,41,44,116,104,105,115,46,35,99,111,110,116,114,97,99,116,115,46,105,110,99,108,117,100,101,115,40,97,100,100,114,101,115,115,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,34,97,108,114,101,97,100,121,32,114,101,103,105,115,116,101,114,101,100,34,41,59,116,104,105,115,46,35,116,111,116,97,108,67,111,110,116,114,97,99,116,115,43,61,49,44,116,104,105,115,46,35,99,111,110,116,114,97,99,116,115,46,112,117,115,104,40,97,100,100,114,101,115,115,41,125,125,114,101,116,117,114,110,32,70,97,99,116,111,114,121,59,2,91,93";
|
|
4
15
|
var nativeToken$2 = "237,198,141,3,53,89,84,113,122,116,99,109,98,57,68,110,99,114,50,116,116,57,77,100,50,104,77,84,106,107,102,72,56,50,68,57,116,118,119,76,106,76,55,78,98,117,67,118,72,111,100,51,114,98,115,70,71,117,163,26,99,108,97,115,115,32,82,111,108,101,115,123,35,114,111,108,101,115,61,123,79,87,78,69,82,58,91,93,44,77,73,78,84,58,91,93,44,66,85,82,78,58,91,93,125,59,99,111,110,115,116,114,117,99,116,111,114,40,114,111,108,101,115,41,123,105,102,40,114,111,108,101,115,41,123,105,102,40,33,40,114,111,108,101,115,32,105,110,115,116,97,110,99,101,111,102,32,79,98,106,101,99,116,41,41,116,104,114,111,119,32,110,101,119,32,84,121,112,101,69,114,114,111,114,40,34,101,120,112,101,99,116,101,100,32,114,111,108,101,115,32,116,111,32,98,101,32,97,110,32,111,98,106,101,99,116,34,41,59,116,104,105,115,46,35,114,111,108,101,115,61,123,46,46,46,114,111,108,101,115,44,46,46,46,116,104,105,115,46,35,114,111,108,101,115,125,125,101,108,115,101,32,116,104,105,115,46,35,103,114,97,110,116,82,111,108,101,40,109,115,103,46,115,101,110,100,101,114,44,34,79,87,78,69,82,34,41,125,103,101,116,32,115,116,97,116,101,40,41,123,114,101,116,117,114,110,123,114,111,108,101,115,58,116,104,105,115,46,114,111,108,101,115,125,125,103,101,116,32,114,111,108,101,115,40,41,123,114,101,116,117,114,110,123,46,46,46,116,104,105,115,46,35,114,111,108,101,115,125,125,104,97,115,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,123,114,101,116,117,114,110,33,33,116,104,105,115,46,35,114,111,108,101,115,91,114,111,108,101,93,38,38,116,104,105,115,46,35,114,111,108,101,115,91,114,111,108,101,93,46,105,110,99,108,117,100,101,115,40,97,100,100,114,101,115,115,41,125,35,103,114,97,110,116,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,123,105,102,40,116,104,105,115,46,104,97,115,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,96,36,123,114,111,108,101,125,32,114,111,108,101,32,97,108,114,101,97,100,121,32,103,114,97,110,116,101,100,32,102,111,114,32,36,123,97,100,100,114,101,115,115,125,96,41,59,116,104,105,115,46,35,114,111,108,101,115,91,114,111,108,101,93,46,112,117,115,104,40,97,100,100,114,101,115,115,41,125,35,114,101,118,111,107,101,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,123,105,102,40,33,116,104,105,115,46,104,97,115,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,96,36,123,114,111,108,101,125,32,114,111,108,101,32,97,108,114,101,97,100,121,32,114,101,118,111,107,101,100,32,102,111,114,32,36,123,97,100,100,114,101,115,115,125,96,41,59,105,102,40,34,79,87,78,69,82,34,61,61,61,114,111,108,101,38,38,49,61,61,61,116,104,105,115,46,35,114,111,108,101,115,91,114,111,108,101,93,46,108,101,110,103,116,104,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,34,97,116,108,101,97,115,116,32,111,110,101,32,111,119,110,101,114,32,105,115,32,110,101,101,100,101,100,33,34,41,59,116,104,105,115,46,35,114,111,108,101,115,91,114,111,108,101,93,46,115,112,108,105,99,101,40,116,104,105,115,46,35,114,111,108,101,115,91,114,111,108,101,93,46,105,110,100,101,120,79,102,40,97,100,100,114,101,115,115,41,41,125,103,114,97,110,116,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,123,105,102,40,33,116,104,105,115,46,104,97,115,82,111,108,101,40,97,100,100,114,101,115,115,44,34,79,87,78,69,82,34,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,34,78,111,116,32,97,108,108,111,119,101,100,34,41,59,116,104,105,115,46,35,103,114,97,110,116,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,125,114,101,118,111,107,101,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,123,105,102,40,33,116,104,105,115,46,104,97,115,82,111,108,101,40,97,100,100,114,101,115,115,44,34,79,87,78,69,82,34,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,34,78,111,116,32,97,108,108,111,119,101,100,34,41,59,116,104,105,115,46,35,114,101,118,111,107,101,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,125,125,99,108,97,115,115,32,84,111,107,101,110,32,101,120,116,101,110,100,115,32,82,111,108,101,115,123,35,110,97,109,101,59,35,115,121,109,98,111,108,59,35,104,111,108,100,101,114,115,61,48,59,35,98,97,108,97,110,99,101,115,61,123,125,59,35,97,112,112,114,111,118,97,108,115,61,123,125,59,35,100,101,99,105,109,97,108,115,61,49,56,59,35,116,111,116,97,108,83,117,112,112,108,121,61,66,105,103,78,117,109,98,101,114,46,102,114,111,109,40,48,41,59,99,111,110,115,116,114,117,99,116,111,114,40,110,97,109,101,44,115,121,109,98,111,108,44,100,101,99,105,109,97,108,115,61,49,56,44,115,116,97,116,101,41,123,105,102,40,33,110,97,109,101,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,34,110,97,109,101,32,117,110,100,101,102,105,110,101,100,34,41,59,105,102,40,33,115,121,109,98,111,108,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,34,115,121,109,98,111,108,32,117,110,100,101,102,105,110,101,100,34,41,59,115,117,112,101,114,40,115,116,97,116,101,63,46,114,111,108,101,115,41,44,116,104,105,115,46,35,110,97,109,101,61,110,97,109,101,44,116,104,105,115,46,35,115,121,109,98,111,108,61,115,121,109,98,111,108,44,116,104,105,115,46,35,100,101,99,105,109,97,108,115,61,100,101,99,105,109,97,108,115,125,103,101,116,32,115,116,97,116,101,40,41,123,114,101,116,117,114,110,123,46,46,46,115,117,112,101,114,46,115,116,97,116,101,44,104,111,108,100,101,114,115,58,116,104,105,115,46,104,111,108,100,101,114,115,44,98,97,108,97,110,99,101,115,58,116,104,105,115,46,98,97,108,97,110,99,101,115,44,97,112,112,114,111,118,97,108,115,58,123,46,46,46,116,104,105,115,46,35,97,112,112,114,111,118,97,108,115,125,44,116,111,116,97,108,83,117,112,112,108,121,58,116,104,105,115,46,116,111,116,97,108,83,117,112,112,108,121,125,125,103,101,116,32,116,111,116,97,108,83,117,112,112,108,121,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,116,111,116,97,108,83,117,112,112,108,121,125,103,101,116,32,110,97,109,101,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,110,97,109,101,125,103,101,116,32,115,121,109,98,111,108,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,115,121,109,98,111,108,125,103,101,116,32,104,111,108,100,101,114,115,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,104,111,108,100,101,114,115,125,103,101,116,32,98,97,108,97,110,99,101,115,40,41,123,114,101,116,117,114,110,123,46,46,46,116,104,105,115,46,35,98,97,108,97,110,99,101,115,125,125,109,105,110,116,40,116,111,44,97,109,111,117,110,116,41,123,105,102,40,33,116,104,105,115,46,104,97,115,82,111,108,101,40,109,115,103,46,115,101,110,100,101,114,44,34,77,73,78,84,34,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,34,110,111,116,32,97,108,108,111,119,101,100,34,41,59,116,104,105,115,46,35,116,111,116,97,108,83,117,112,112,108,121,61,116,104,105,115,46,35,116,111,116,97,108,83,117,112,112,108,121,46,97,100,100,40,97,109,111,117,110,116,41,44,116,104,105,115,46,35,105,110,99,114,101,97,115,101,66,97,108,97,110,99,101,40,116,111,44,97,109,111,117,110,116,41,125,98,117,114,110,40,102,114,111,109,44,97,109,111,117,110,116,41,123,105,102,40,33,116,104,105,115,46,104,97,115,82,111,108,101,40,109,115,103,46,115,101,110,100,101,114,44,34,66,85,82,78,34,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,34,110,111,116,32,97,108,108,111,119,101,100,34,41,59,116,104,105,115,46,35,116,111,116,97,108,83,117,112,112,108,121,61,116,104,105,115,46,35,116,111,116,97,108,83,117,112,112,108,121,46,115,117,98,40,97,109,111,117,110,116,41,44,116,104,105,115,46,35,100,101,99,114,101,97,115,101,66,97,108,97,110,99,101,40,102,114,111,109,44,97,109,111,117,110,116,41,125,35,98,101,102,111,114,101,84,114,97,110,115,102,101,114,40,102,114,111,109,44,116,111,44,97,109,111,117,110,116,41,123,105,102,40,33,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,102,114,111,109,93,124,124,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,102,114,111,109,93,60,97,109,111,117,110,116,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,34,97,109,111,117,110,116,32,101,120,99,101,101,100,115,32,98,97,108,97,110,99,101,34,41,125,35,117,112,100,97,116,101,72,111,108,100,101,114,115,40,97,100,100,114,101,115,115,44,112,114,101,118,105,111,117,115,66,97,108,97,110,99,101,41,123,34,48,120,48,48,34,61,61,61,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,46,116,111,72,101,120,83,116,114,105,110,103,40,41,63,116,104,105,115,46,35,104,111,108,100,101,114,115,45,61,49,58,34,48,120,48,48,34,33,61,61,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,46,116,111,72,101,120,83,116,114,105,110,103,40,41,38,38,34,48,120,48,48,34,61,61,61,112,114,101,118,105,111,117,115,66,97,108,97,110,99,101,46,116,111,72,101,120,83,116,114,105,110,103,40,41,38,38,40,116,104,105,115,46,35,104,111,108,100,101,114,115,43,61,49,41,125,35,105,110,99,114,101,97,115,101,66,97,108,97,110,99,101,40,97,100,100,114,101,115,115,44,97,109,111,117,110,116,41,123,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,124,124,40,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,61,66,105,103,78,117,109,98,101,114,46,102,114,111,109,40,48,41,41,59,99,111,110,115,116,32,112,114,101,118,105,111,117,115,66,97,108,97,110,99,101,61,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,59,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,61,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,46,97,100,100,40,97,109,111,117,110,116,41,44,116,104,105,115,46,35,117,112,100,97,116,101,72,111,108,100,101,114,115,40,97,100,100,114,101,115,115,44,112,114,101,118,105,111,117,115,66,97,108,97,110,99,101,41,125,35,100,101,99,114,101,97,115,101,66,97,108,97,110,99,101,40,97,100,100,114,101,115,115,44,97,109,111,117,110,116,41,123,99,111,110,115,116,32,112,114,101,118,105,111,117,115,66,97,108,97,110,99,101,61,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,59,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,61,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,46,115,117,98,40,97,109,111,117,110,116,41,44,116,104,105,115,46,35,117,112,100,97,116,101,72,111,108,100,101,114,115,40,97,100,100,114,101,115,115,44,112,114,101,118,105,111,117,115,66,97,108,97,110,99,101,41,125,98,97,108,97,110,99,101,79,102,40,97,100,100,114,101,115,115,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,125,115,101,116,65,112,112,114,111,118,97,108,40,111,112,101,114,97,116,111,114,44,97,109,111,117,110,116,41,123,99,111,110,115,116,32,111,119,110,101,114,61,109,115,103,46,115,101,110,100,101,114,59,116,104,105,115,46,35,97,112,112,114,111,118,97,108,115,91,111,119,110,101,114,93,124,124,40,116,104,105,115,46,35,97,112,112,114,111,118,97,108,115,91,111,119,110,101,114,93,61,123,125,41,44,116,104,105,115,46,35,97,112,112,114,111,118,97,108,115,91,111,119,110,101,114,93,91,111,112,101,114,97,116,111,114,93,61,97,109,111,117,110,116,125,97,112,112,114,111,118,101,100,40,111,119,110,101,114,44,111,112,101,114,97,116,111,114,44,97,109,111,117,110,116,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,97,112,112,114,111,118,97,108,115,91,111,119,110,101,114,93,91,111,112,101,114,97,116,111,114,93,61,61,61,97,109,111,117,110,116,125,116,114,97,110,115,102,101,114,40,102,114,111,109,44,116,111,44,97,109,111,117,110,116,41,123,97,109,111,117,110,116,61,66,105,103,78,117,109,98,101,114,46,102,114,111,109,40,97,109,111,117,110,116,41,44,116,104,105,115,46,35,98,101,102,111,114,101,84,114,97,110,115,102,101,114,40,102,114,111,109,44,116,111,44,97,109,111,117,110,116,41,44,116,104,105,115,46,35,100,101,99,114,101,97,115,101,66,97,108,97,110,99,101,40,102,114,111,109,44,97,109,111,117,110,116,41,44,116,104,105,115,46,35,105,110,99,114,101,97,115,101,66,97,108,97,110,99,101,40,116,111,44,97,109,111,117,110,116,41,125,125,99,108,97,115,115,32,65,114,116,79,110,108,105,110,101,32,101,120,116,101,110,100,115,32,84,111,107,101,110,123,99,111,110,115,116,114,117,99,116,111,114,40,115,116,97,116,101,41,123,115,117,112,101,114,40,34,65,114,116,79,110,108,105,110,101,34,44,34,65,82,84,34,44,49,56,44,115,116,97,116,101,41,125,125,114,101,116,117,114,110,32,65,114,116,79,110,108,105,110,101,59,2,91,93";
|
|
@@ -44,7 +55,7 @@ const _ = {};
|
|
|
44
55
|
|
|
45
56
|
globalThis.BigNumber = BigNumber;
|
|
46
57
|
|
|
47
|
-
let lastBlock = { index:
|
|
58
|
+
let lastBlock = { index: -1, hash: '0x0', previousHash: '0x0' };
|
|
48
59
|
|
|
49
60
|
const has = (address) => {
|
|
50
61
|
return contracts[address] ? true : false
|
|
@@ -112,6 +123,35 @@ const createMessage = (sender = globalThis.peerid) => {
|
|
|
112
123
|
}
|
|
113
124
|
};
|
|
114
125
|
|
|
126
|
+
const _executeTransaction = async (transaction) => {
|
|
127
|
+
const hash = await new TransactionMessage(transaction).hash();
|
|
128
|
+
if (latestTransactions.includes(hash)) {
|
|
129
|
+
throw new Error(`double transaction found: ${hash} in block ${block.index}`)
|
|
130
|
+
} else {
|
|
131
|
+
latestTransactions.push(hash);
|
|
132
|
+
const { from, to, method, params, nonce } = transaction;
|
|
133
|
+
globalThis.msg = createMessage(from);
|
|
134
|
+
|
|
135
|
+
await _.execute({ contract: to, method, params });
|
|
136
|
+
if (to === nativeToken) {
|
|
137
|
+
nativeCalls += 1;
|
|
138
|
+
if (method === 'burn') nativeBurns += 1;
|
|
139
|
+
if (method === 'mint') nativeMints += 1;
|
|
140
|
+
if (method === 'transfer') nativeTransfers += 1;
|
|
141
|
+
}
|
|
142
|
+
totalTransactions += 1;
|
|
143
|
+
|
|
144
|
+
worker.postMessage({
|
|
145
|
+
type: 'transactionLoaded',
|
|
146
|
+
result: {
|
|
147
|
+
hash,
|
|
148
|
+
from,
|
|
149
|
+
nonce: String(nonce)
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
|
|
115
155
|
_.init = async (message) => {
|
|
116
156
|
let { contracts, peerid } = message;
|
|
117
157
|
globalThis.peerid = peerid;
|
|
@@ -157,38 +197,20 @@ _.init = async (message) => {
|
|
|
157
197
|
const transactionCount = blocks[block.index - 1].transactions.length;
|
|
158
198
|
latestTransactions.splice(-(transactionCount - 1), latestTransactions.length);
|
|
159
199
|
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
if (method === 'burn') nativeBurns += 1;
|
|
175
|
-
if (method === 'mint') nativeMints += 1;
|
|
176
|
-
if (method === 'transfer') nativeTransfers += 1;
|
|
177
|
-
}
|
|
178
|
-
totalTransactions += 1;
|
|
179
|
-
|
|
180
|
-
worker.postMessage({
|
|
181
|
-
type: 'transactionLoaded',
|
|
182
|
-
result: {
|
|
183
|
-
hash,
|
|
184
|
-
from,
|
|
185
|
-
nonce: String(nonce)
|
|
186
|
-
}
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
})
|
|
191
|
-
);
|
|
200
|
+
|
|
201
|
+
if (!block.loaded) {
|
|
202
|
+
const priority = block.transactions.filter((transaction) => transaction.priority);
|
|
203
|
+
if (priority.length > 0)
|
|
204
|
+
await Promise.all(
|
|
205
|
+
priority.sort((a, b) => a.nonce - b.nonce).map((transaction) => _executeTransaction(transaction))
|
|
206
|
+
);
|
|
207
|
+
|
|
208
|
+
await Promise.all(
|
|
209
|
+
block.transactions
|
|
210
|
+
.filter((transaction) => !transaction.priority)
|
|
211
|
+
.map(async (transaction) => _executeTransaction(transaction))
|
|
212
|
+
);
|
|
213
|
+
}
|
|
192
214
|
block.loaded = true;
|
|
193
215
|
worker.postMessage({
|
|
194
216
|
type: 'debug',
|
|
@@ -281,7 +303,7 @@ worker.onmessage(({ id, type, input }) => {
|
|
|
281
303
|
respond(id, blocks[input - 1]);
|
|
282
304
|
break
|
|
283
305
|
case 'lastBlock':
|
|
284
|
-
respond(id, blocks[blocks.length - 1]);
|
|
306
|
+
respond(id, blocks[blocks.length - 1] || lastBlock);
|
|
285
307
|
break
|
|
286
308
|
case 'latestTransactions':
|
|
287
309
|
respond(id, latestTransactions);
|
|
@@ -4127,17 +4127,6 @@ function throwFault(fault, operation, value) {
|
|
|
4127
4127
|
return logger.throwError(fault, Logger.errors.NUMERIC_FAULT, params);
|
|
4128
4128
|
}
|
|
4129
4129
|
|
|
4130
|
-
const byteFormats = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
|
4131
|
-
const formatBytes = (bytes, decimals = 2) => {
|
|
4132
|
-
if (bytes === 0)
|
|
4133
|
-
return '0 Bytes';
|
|
4134
|
-
if (decimals < 0)
|
|
4135
|
-
decimals = 0;
|
|
4136
|
-
const k = 1024;
|
|
4137
|
-
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
4138
|
-
return `${parseFloat((bytes / Math.pow(k, i)).toFixed(decimals))} ${byteFormats[i]}`;
|
|
4139
|
-
};
|
|
4140
|
-
|
|
4141
4130
|
// base-x encoding / decoding
|
|
4142
4131
|
// Copyright (c) 2018 base-x contributors
|
|
4143
4132
|
// Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp)
|
|
@@ -12441,56 +12430,55 @@ class ValidatorMessage extends FormatInterface {
|
|
|
12441
12430
|
}
|
|
12442
12431
|
|
|
12443
12432
|
var proto$1 = {
|
|
12444
|
-
|
|
12445
|
-
|
|
12446
|
-
|
|
12447
|
-
|
|
12448
|
-
|
|
12449
|
-
|
|
12450
|
-
|
|
12433
|
+
index: Number(),
|
|
12434
|
+
previousHash: String(),
|
|
12435
|
+
timestamp: Number(),
|
|
12436
|
+
reward: BigNumber.from(0),
|
|
12437
|
+
fees: BigNumber.from(0),
|
|
12438
|
+
transactions: new Uint8Array(),
|
|
12439
|
+
validators: new Uint8Array()
|
|
12451
12440
|
};
|
|
12452
12441
|
|
|
12453
12442
|
class BlockMessage extends FormatInterface {
|
|
12454
|
-
|
|
12455
|
-
|
|
12456
|
-
|
|
12457
|
-
|
|
12458
|
-
|
|
12459
|
-
|
|
12460
|
-
|
|
12461
|
-
|
|
12462
|
-
|
|
12463
|
-
|
|
12464
|
-
|
|
12465
|
-
|
|
12466
|
-
|
|
12467
|
-
|
|
12468
|
-
|
|
12469
|
-
|
|
12470
|
-
|
|
12471
|
-
|
|
12472
|
-
|
|
12473
|
-
|
|
12474
|
-
|
|
12475
|
-
|
|
12476
|
-
|
|
12477
|
-
|
|
12478
|
-
|
|
12479
|
-
|
|
12480
|
-
|
|
12481
|
-
|
|
12482
|
-
|
|
12483
|
-
|
|
12484
|
-
|
|
12485
|
-
|
|
12486
|
-
|
|
12487
|
-
|
|
12488
|
-
|
|
12489
|
-
|
|
12490
|
-
|
|
12491
|
-
|
|
12492
|
-
|
|
12493
|
-
}
|
|
12443
|
+
get messageName() {
|
|
12444
|
+
return 'BlockMessage'
|
|
12445
|
+
}
|
|
12446
|
+
constructor(buffer) {
|
|
12447
|
+
if (buffer instanceof BlockMessage) return buffer
|
|
12448
|
+
const name = 'block-message';
|
|
12449
|
+
super(buffer, proto$1, { name });
|
|
12450
|
+
}
|
|
12451
|
+
encode(decoded) {
|
|
12452
|
+
decoded = decoded || this.decoded;
|
|
12453
|
+
const validators = [];
|
|
12454
|
+
const transactions = [];
|
|
12455
|
+
for (const validator of decoded.validators) {
|
|
12456
|
+
if (validator instanceof ValidatorMessage) validators.push(validator.encode());
|
|
12457
|
+
else validators.push(new ValidatorMessage(validator).encode());
|
|
12458
|
+
}
|
|
12459
|
+
for (const transaction of decoded.transactions) {
|
|
12460
|
+
if (transaction instanceof TransactionMessage) transactions.push(transaction.encode());
|
|
12461
|
+
else transactions.push(new TransactionMessage(transaction).encode());
|
|
12462
|
+
}
|
|
12463
|
+
return super.encode({
|
|
12464
|
+
...decoded,
|
|
12465
|
+
validators: index$5(validators),
|
|
12466
|
+
transactions: index$5(transactions)
|
|
12467
|
+
})
|
|
12468
|
+
}
|
|
12469
|
+
decode(encoded) {
|
|
12470
|
+
encoded = encoded || this.encoded;
|
|
12471
|
+
super.decode(encoded);
|
|
12472
|
+
// @ts-ignore
|
|
12473
|
+
this.decoded.transactions = index$4(this.decoded.transactions).map(
|
|
12474
|
+
(transaction) => new TransactionMessage(transaction).decoded
|
|
12475
|
+
);
|
|
12476
|
+
// @ts-ignore
|
|
12477
|
+
this.decoded.validators = index$4(this.decoded.validators).map(
|
|
12478
|
+
(validator) => new ValidatorMessage(validator).decoded
|
|
12479
|
+
);
|
|
12480
|
+
return this.decoded
|
|
12481
|
+
}
|
|
12494
12482
|
}
|
|
12495
12483
|
|
|
12496
12484
|
var proto = {
|
|
@@ -12597,4 +12585,4 @@ class EasyWorker {
|
|
|
12597
12585
|
}
|
|
12598
12586
|
}
|
|
12599
12587
|
|
|
12600
|
-
export { BigNumber as B, ContractMessage as C, EasyWorker as E, TransactionMessage as T, BlockMessage as a
|
|
12588
|
+
export { BigNumber as B, ContractMessage as C, EasyWorker as E, TransactionMessage as T, BlockMessage as a };
|
package/exports/chain.d.ts
CHANGED
package/exports/chain.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import '@vandeurenglenn/debug';
|
|
1
2
|
import { formatBytes, BigNumber, formatUnits, parseUnits } from '@leofcoin/utils';
|
|
2
3
|
import { TransactionMessage, BlockMessage, ContractMessage, BWMessage, BWRequestMessage } from '@leofcoin/messages';
|
|
3
4
|
import addresses, { contractFactory, nativeToken, validators, nameService } from '@leofcoin/addresses';
|
|
@@ -270,6 +271,7 @@ class Contract extends Transaction {
|
|
|
270
271
|
}
|
|
271
272
|
|
|
272
273
|
// import State from './state'
|
|
274
|
+
const debug$2 = globalThis.createDebugger('leofcoin/machine');
|
|
273
275
|
class Machine {
|
|
274
276
|
#contracts = {};
|
|
275
277
|
#nonces = {};
|
|
@@ -309,7 +311,10 @@ class Machine {
|
|
|
309
311
|
break;
|
|
310
312
|
}
|
|
311
313
|
case 'debug': {
|
|
312
|
-
|
|
314
|
+
debug$2(data.message);
|
|
315
|
+
if (data.message.includes('loaded transactions for block:')) {
|
|
316
|
+
pubsub.publish('block-loaded', data.message.replace('loaded transactions for block: ', '').split(' @')[0]);
|
|
317
|
+
}
|
|
313
318
|
break;
|
|
314
319
|
}
|
|
315
320
|
case 'error': {
|
|
@@ -584,6 +589,7 @@ class Jobber {
|
|
|
584
589
|
}
|
|
585
590
|
}
|
|
586
591
|
|
|
592
|
+
const debug$1 = globalThis.createDebugger('leofcoin/state');
|
|
587
593
|
class State extends Contract {
|
|
588
594
|
#resolveErrored;
|
|
589
595
|
#lastResolvedTime;
|
|
@@ -680,7 +686,7 @@ class State extends Contract {
|
|
|
680
686
|
this.#getLastTransactions = async () => {
|
|
681
687
|
let lastTransactions = (await Promise.all((await this.blocks)
|
|
682
688
|
.filter((block) => block.loaded)
|
|
683
|
-
.slice(-
|
|
689
|
+
.slice(-24)
|
|
684
690
|
.map((block) => this.#loadBlockTransactions(block.transactions)))).reduce((all, transactions) => [...all, ...transactions], []);
|
|
685
691
|
return Promise.all(lastTransactions.map((transaction) => transaction.hash()));
|
|
686
692
|
};
|
|
@@ -738,10 +744,15 @@ class State extends Contract {
|
|
|
738
744
|
}
|
|
739
745
|
}
|
|
740
746
|
async updateState(message) {
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
747
|
+
try {
|
|
748
|
+
const hash = await message.hash();
|
|
749
|
+
// await this.state.updateState(message)
|
|
750
|
+
await globalThis.chainStore.put('lastBlock', hash);
|
|
751
|
+
globalThis.pubsub.publish('lastBlock', message.encoded);
|
|
752
|
+
}
|
|
753
|
+
catch (error) {
|
|
754
|
+
console.error(error);
|
|
755
|
+
}
|
|
745
756
|
}
|
|
746
757
|
getLatestBlock() {
|
|
747
758
|
// @ts-ignore
|
|
@@ -777,7 +788,7 @@ class State extends Contract {
|
|
|
777
788
|
this.#totalSize += size;
|
|
778
789
|
this.#blocks[index - 1] = { hash, ...block.decoded };
|
|
779
790
|
this.#blockHashMap.set(hash, index);
|
|
780
|
-
|
|
791
|
+
debug$1(`resolved block: ${hash} @${index} ${formatBytes(size)}`);
|
|
781
792
|
globalThis.pubsub.publish('block-resolved', { hash, index });
|
|
782
793
|
this.#lastResolved = this.#blocks[index - 1];
|
|
783
794
|
this.#lastResolvedTime = Date.now();
|
|
@@ -915,7 +926,7 @@ class State extends Contract {
|
|
|
915
926
|
await this.resolveBlock(lastBlock.hash);
|
|
916
927
|
console.log('ok');
|
|
917
928
|
let blocksSynced = localIndex > 0 ? (localIndex > index ? localIndex - index : index + -localIndex) : index;
|
|
918
|
-
|
|
929
|
+
debug$1(`synced ${blocksSynced} ${blocksSynced > 1 ? 'blocks' : 'block'}`);
|
|
919
930
|
const blocks = this.#blocks;
|
|
920
931
|
const start = blocks.length - blocksSynced;
|
|
921
932
|
if (this.#machine) {
|
|
@@ -1047,7 +1058,7 @@ class State extends Contract {
|
|
|
1047
1058
|
this.#blocks[block.index - 1].loaded = true;
|
|
1048
1059
|
await this.#machine.addLoadedBlock(block);
|
|
1049
1060
|
// @ts-ignore
|
|
1050
|
-
|
|
1061
|
+
debug$1(`loaded block: ${block.hash} @${block.index}`);
|
|
1051
1062
|
globalThis.pubsub.publish('block-loaded', { ...block });
|
|
1052
1063
|
}
|
|
1053
1064
|
}
|
|
@@ -1058,7 +1069,7 @@ class State extends Contract {
|
|
|
1058
1069
|
return new Promise(async (resolve, reject) => {
|
|
1059
1070
|
const timeout = setTimeout(() => {
|
|
1060
1071
|
resolve([{ index: 0, hash: '0x0' }]);
|
|
1061
|
-
|
|
1072
|
+
debug$1('sync timed out');
|
|
1062
1073
|
}, this.requestTimeout);
|
|
1063
1074
|
promises = await Promise.allSettled(promises);
|
|
1064
1075
|
promises = promises.filter(({ status }) => status === 'fulfilled');
|
|
@@ -1142,7 +1153,7 @@ class VersionControl extends State {
|
|
|
1142
1153
|
}
|
|
1143
1154
|
|
|
1144
1155
|
globalThis.BigNumber = BigNumber;
|
|
1145
|
-
const
|
|
1156
|
+
const debug = globalThis.createDebugger('leofcoin/chain');
|
|
1146
1157
|
// check if browser or local
|
|
1147
1158
|
class Chain extends VersionControl {
|
|
1148
1159
|
#state;
|
|
@@ -1169,7 +1180,7 @@ class Chain extends VersionControl {
|
|
|
1169
1180
|
const transaction = new TransactionMessage(message);
|
|
1170
1181
|
await transaction.hash();
|
|
1171
1182
|
// if (await transactionPoolStore.has(hash)) await transactionPoolStore.delete(hash)
|
|
1172
|
-
|
|
1183
|
+
debug(`added ${transaction}`);
|
|
1173
1184
|
};
|
|
1174
1185
|
// @ts-ignore
|
|
1175
1186
|
return this.#init();
|
|
@@ -1292,7 +1303,6 @@ class Chain extends VersionControl {
|
|
|
1292
1303
|
const transactionsToGet = [];
|
|
1293
1304
|
for (const key of transactionsInPool) {
|
|
1294
1305
|
!transactions.includes(key) &&
|
|
1295
|
-
!ignorelist.includes(key) &&
|
|
1296
1306
|
transactionsToGet.push(transactionPoolStore.put(key, await peernet.get(key, 'transaction')));
|
|
1297
1307
|
}
|
|
1298
1308
|
return Promise.all(transactionsToGet);
|
|
@@ -1301,7 +1311,10 @@ class Chain extends VersionControl {
|
|
|
1301
1311
|
const peer = peernet.getConnection(peerId);
|
|
1302
1312
|
// todo handle version changes
|
|
1303
1313
|
// for now just do nothing if version doesn't match
|
|
1304
|
-
|
|
1314
|
+
debug(`peer connected with version ${peer.version}`);
|
|
1315
|
+
if (peer.version !== this.version) {
|
|
1316
|
+
debug(`versions don't match`);
|
|
1317
|
+
}
|
|
1305
1318
|
if (!peer.version || peer.version !== this.version)
|
|
1306
1319
|
return;
|
|
1307
1320
|
const lastBlock = await this.#makeRequest(peer, 'lastBlock');
|
|
@@ -1360,7 +1373,7 @@ class Chain extends VersionControl {
|
|
|
1360
1373
|
await globalThis.blockStore.put(hash, blockMessage.encoded);
|
|
1361
1374
|
if ((await this.lastBlock).index < Number(blockMessage.decoded.index))
|
|
1362
1375
|
await this.updateState(blockMessage);
|
|
1363
|
-
|
|
1376
|
+
debug(`added block: ${hash}`);
|
|
1364
1377
|
let promises = [];
|
|
1365
1378
|
let contracts = [];
|
|
1366
1379
|
for (let transaction of blockMessage.decoded.transactions) {
|
|
@@ -1418,16 +1431,41 @@ class Chain extends VersionControl {
|
|
|
1418
1431
|
if ((await this.hasTransactionToHandle()) && !this.#runningEpoch && this.#participating)
|
|
1419
1432
|
await this.#runEpoch();
|
|
1420
1433
|
}
|
|
1434
|
+
async #handleTransaction(transaction, latestTransactions, block) {
|
|
1435
|
+
const hash = await transaction.hash();
|
|
1436
|
+
const doubleTransactions = [];
|
|
1437
|
+
if (latestTransactions.includes(hash)) {
|
|
1438
|
+
doubleTransactions.push(hash);
|
|
1439
|
+
}
|
|
1440
|
+
if (doubleTransactions.length > 0) {
|
|
1441
|
+
await globalThis.transactionPoolStore.delete(hash);
|
|
1442
|
+
await globalThis.peernet.publish('invalid-transaction', hash);
|
|
1443
|
+
return;
|
|
1444
|
+
}
|
|
1445
|
+
// if (timestamp + this.#slotTime > Date.now()) {
|
|
1446
|
+
try {
|
|
1447
|
+
const result = await this.#executeTransaction({ ...transaction.decoded, hash });
|
|
1448
|
+
block.transactions.push(transaction);
|
|
1449
|
+
block.fees = block.fees.add(await calculateFee(transaction.decoded));
|
|
1450
|
+
await globalThis.accountsStore.put(transaction.decoded.from, new TextEncoder().encode(String(transaction.decoded.nonce)));
|
|
1451
|
+
}
|
|
1452
|
+
catch (e) {
|
|
1453
|
+
console.log('vvvvvv');
|
|
1454
|
+
console.log({ e });
|
|
1455
|
+
console.log(hash);
|
|
1456
|
+
peernet.publish('invalid-transaction', hash);
|
|
1457
|
+
console.log(await globalThis.transactionPoolStore.keys());
|
|
1458
|
+
console.log(await globalThis.transactionPoolStore.has(e.hash));
|
|
1459
|
+
await globalThis.transactionPoolStore.delete(e.hash);
|
|
1460
|
+
console.log(await globalThis.transactionPoolStore.has(e.hash));
|
|
1461
|
+
}
|
|
1462
|
+
}
|
|
1421
1463
|
// todo filter tx that need to wait on prev nonce
|
|
1422
1464
|
async #createBlock(limit = this.transactionLimit) {
|
|
1423
1465
|
// vote for transactions
|
|
1424
1466
|
if ((await globalThis.transactionPoolStore.size()) === 0)
|
|
1425
1467
|
return;
|
|
1426
1468
|
let transactions = await globalThis.transactionPoolStore.values(this.transactionLimit);
|
|
1427
|
-
for (const hash of await globalThis.transactionPoolStore.keys()) {
|
|
1428
|
-
if (ignorelist.includes(hash))
|
|
1429
|
-
await globalThis.transactionPoolStore.delete(hash);
|
|
1430
|
-
}
|
|
1431
1469
|
if (Object.keys(transactions)?.length === 0)
|
|
1432
1470
|
return;
|
|
1433
1471
|
const timestamp = Date.now();
|
|
@@ -1440,39 +1478,16 @@ class Chain extends VersionControl {
|
|
|
1440
1478
|
reward: parseUnits('150'),
|
|
1441
1479
|
index: 0
|
|
1442
1480
|
};
|
|
1481
|
+
const latestTransactions = await this.machine.latestTransactions();
|
|
1443
1482
|
// exclude failing tx
|
|
1444
1483
|
transactions = await this.promiseTransactions(transactions);
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
}
|
|
1453
|
-
if (doubleTransactions.length > 0) {
|
|
1454
|
-
await globalThis.transactionPoolStore.delete(hash);
|
|
1455
|
-
await globalThis.peernet.publish('invalid-transaction', hash);
|
|
1456
|
-
return;
|
|
1457
|
-
}
|
|
1458
|
-
// if (timestamp + this.#slotTime > Date.now()) {
|
|
1459
|
-
try {
|
|
1460
|
-
const result = await this.#executeTransaction({ ...transaction.decoded, hash });
|
|
1461
|
-
block.transactions.push(transaction);
|
|
1462
|
-
block.fees = block.fees.add(await calculateFee(transaction.decoded));
|
|
1463
|
-
await globalThis.accountsStore.put(transaction.decoded.from, new TextEncoder().encode(String(transaction.decoded.nonce)));
|
|
1464
|
-
}
|
|
1465
|
-
catch (e) {
|
|
1466
|
-
console.log('vvvvvv');
|
|
1467
|
-
console.log({ e });
|
|
1468
|
-
console.log(hash);
|
|
1469
|
-
peernet.publish('invalid-transaction', hash);
|
|
1470
|
-
console.log(await globalThis.transactionPoolStore.keys());
|
|
1471
|
-
console.log(await globalThis.transactionPoolStore.has(e.hash));
|
|
1472
|
-
await globalThis.transactionPoolStore.delete(e.hash);
|
|
1473
|
-
console.log(await globalThis.transactionPoolStore.has(e.hash));
|
|
1474
|
-
}
|
|
1475
|
-
}
|
|
1484
|
+
const priority = transactions.filter((transaction) => transaction.priority);
|
|
1485
|
+
await Promise.all(priority
|
|
1486
|
+
.sort((a, b) => a.nonce - b.nonce)
|
|
1487
|
+
.map((transaction) => this.#handleTransaction(transaction, latestTransactions, block)));
|
|
1488
|
+
await Promise.all(transactions
|
|
1489
|
+
.filter((transaction) => !transaction.priority)
|
|
1490
|
+
.map((transaction) => this.#handleTransaction(transaction, latestTransactions, block)));
|
|
1476
1491
|
// don't add empty block
|
|
1477
1492
|
if (block.transactions.length === 0)
|
|
1478
1493
|
return;
|
|
@@ -1539,7 +1554,7 @@ class Chain extends VersionControl {
|
|
|
1539
1554
|
await globalThis.peernet.put(hash, blockMessage.encoded, 'block');
|
|
1540
1555
|
await this.updateState(blockMessage);
|
|
1541
1556
|
await this.machine.addLoadedBlock({ ...blockMessage.decoded, loaded: true, hash: await blockMessage.hash() });
|
|
1542
|
-
|
|
1557
|
+
debug(`created block: ${hash} @${block.index}`);
|
|
1543
1558
|
globalThis.peernet.publish('add-block', blockMessage.encoded);
|
|
1544
1559
|
globalThis.pubsub.publish('add-block', blockMessage.decoded);
|
|
1545
1560
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { E as EasyWorker, B as BigNumber, a as BlockMessage
|
|
1
|
+
import { E as EasyWorker, B as BigNumber, a as BlockMessage } from './worker-hbo9s9AT.js';
|
|
2
2
|
|
|
3
3
|
const worker = new EasyWorker();
|
|
4
4
|
|
|
@@ -18,9 +18,6 @@ const run = async (blocks) => {
|
|
|
18
18
|
const size = block.encoded.length || block.encoded.byteLength;
|
|
19
19
|
const hash = await block.hash();
|
|
20
20
|
const index = block.decoded.index;
|
|
21
|
-
console.log(`loaded block: ${hash} @${index} ${formatBytes(size)}`);
|
|
22
|
-
// todo we don't want this, need shared state
|
|
23
|
-
block.decoded.transactions = block.decoded.transactions.sort((a, b) => a.nonce - b.nonce);
|
|
24
21
|
resolve({ ...block.decoded, hash, blockInfo: { hash, size, index } });
|
|
25
22
|
})
|
|
26
23
|
)
|