@leofcoin/workers 1.1.1 → 1.2.1

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.
Files changed (56) hide show
  1. package/dist/bundle/commonjs/block-worker-21ad8152.js +45 -0
  2. package/dist/bundle/commonjs/block-worker.js +4 -5
  3. package/dist/bundle/commonjs/{machine-worker-28ffe20b.js → machine-worker-e96e3082.js} +25 -20
  4. package/dist/bundle/commonjs/machine-worker.js +3 -4
  5. package/dist/bundle/commonjs/{pool-worker-61189fde.js → pool-worker-f450eeff.js} +6 -17
  6. package/dist/bundle/commonjs/pool-worker.js +3 -3
  7. package/dist/bundle/commonjs/{transaction-6a24c91e.js → transaction-d7c6a8ee.js} +2 -2
  8. package/dist/bundle/commonjs/transaction-worker-176a5aaa.js +27 -0
  9. package/dist/bundle/commonjs/transaction-worker.js +3 -3
  10. package/dist/bundle/commonjs/{utils-6a02b156.js → utils-6e881be4.js} +45 -2
  11. package/dist/bundle/commonjs/{index-f77ba3de.js → worker-6ace445f.js} +97 -0
  12. package/dist/bundle/commonjs/workers.js +7 -8
  13. package/dist/bundle/module/block-worker-414860e0.js +43 -0
  14. package/dist/bundle/module/block-worker.js +4 -5
  15. package/dist/bundle/module/{machine-worker-5f6457bd.js → machine-worker-e3020b69.js} +24 -19
  16. package/dist/bundle/module/machine-worker.js +3 -4
  17. package/dist/bundle/module/{pool-worker-012d12c9.js → pool-worker-0d927e3c.js} +6 -17
  18. package/dist/bundle/module/pool-worker.js +3 -3
  19. package/dist/bundle/module/{transaction-e9126d7b.js → transaction-cec98ce8.js} +1 -1
  20. package/dist/bundle/module/transaction-worker-548cd200.js +25 -0
  21. package/dist/bundle/module/transaction-worker.js +3 -3
  22. package/dist/bundle/module/{utils-d240ed61.js → utils-ac8c68e6.js} +44 -2
  23. package/dist/bundle/module/{index-6715242b.js → worker-def77c26.js} +79 -1
  24. package/dist/bundle/module/workers.js +7 -8
  25. package/dist/commonjs/block-worker-60e4cfa3.js +50 -0
  26. package/dist/commonjs/block-worker.js +3 -4
  27. package/dist/commonjs/{machine-worker-5e1073c1.js → machine-worker-16dad57f.js} +28 -18
  28. package/dist/commonjs/machine-worker.js +3 -3
  29. package/dist/commonjs/{pool-worker-3d581327.js → pool-worker-81e8b4c0.js} +9 -15
  30. package/dist/commonjs/pool-worker.js +2 -1
  31. package/dist/commonjs/transaction-worker-8eecc7a1.js +32 -0
  32. package/dist/commonjs/transaction-worker.js +2 -1
  33. package/dist/commonjs/{utils-def2fce8.js → utils-1dc37f72.js} +44 -0
  34. package/dist/commonjs/workers.js +6 -6
  35. package/dist/module/block-worker-f539b1b2.js +44 -0
  36. package/dist/module/block-worker.js +3 -4
  37. package/dist/module/{machine-worker-12c3eda2.js → machine-worker-a2897101.js} +24 -18
  38. package/dist/module/machine-worker.js +3 -3
  39. package/dist/module/{pool-worker-8d3369b4.js → pool-worker-f65671d7.js} +5 -15
  40. package/dist/module/pool-worker.js +2 -1
  41. package/dist/module/{transaction-worker-0f96397e.js → transaction-worker-105deaa8.js} +11 -18
  42. package/dist/module/transaction-worker.js +2 -1
  43. package/dist/module/{utils-96ad7b3e.js → utils-e87bc63d.js} +44 -1
  44. package/dist/module/workers.js +6 -6
  45. package/package.json +22 -22
  46. package/src/block-worker.js +13 -45
  47. package/src/machine-worker.js +25 -18
  48. package/src/pool-worker.js +7 -16
  49. package/src/transaction-worker.js +13 -19
  50. package/dist/bundle/commonjs/block-worker-81701b46.js +0 -116
  51. package/dist/bundle/commonjs/transaction-worker-90623101.js +0 -35
  52. package/dist/bundle/module/block-worker-6f72caf6.js +0 -114
  53. package/dist/bundle/module/transaction-worker-8afddd7e.js +0 -33
  54. package/dist/commonjs/block-worker-9ae351ea.js +0 -116
  55. package/dist/commonjs/transaction-worker-02476daf.js +0 -35
  56. package/dist/module/block-worker-d07e9a9f.js +0 -114
@@ -1,116 +0,0 @@
1
- 'use strict';
2
-
3
- var index = require('./index-f77ba3de.js');
4
- var utils = require('./utils-6a02b156.js');
5
- var child_process = require('child_process');
6
- var require$$1 = require('path');
7
-
8
- var proto = `
9
- message ValidatorMessage {
10
- required string address = 1;
11
- required string reward = 2;
12
- }
13
-
14
- message Transaction {
15
- required string hash = 1;
16
- required uint64 timestamp = 2;
17
- required string from = 3;
18
- required string to = 4;
19
- required uint64 nonce = 5;
20
- required string method = 6;
21
- repeated string params = 7;
22
- }
23
-
24
- message BlockMessage {
25
- required uint64 index = 1;
26
- required string previousHash = 3;
27
- required uint64 timestamp = 4;
28
- required uint64 reward = 5;
29
- required string fees = 6;
30
- repeated Transaction transactions = 7;
31
- repeated ValidatorMessage validators = 8;
32
- }
33
- `;
34
-
35
- class BlockMessage extends index.FormatInterface_1 {
36
- get keys() {
37
- return ['index', 'previousHash', 'timestamp', 'reward', 'fees', 'transactions', 'validators']
38
- }
39
-
40
- get messageName() {
41
- return 'BlockMessage'
42
- }
43
-
44
- constructor(buffer) {
45
- const name = 'block-message';
46
- super(buffer, proto, {name});
47
- }
48
- }
49
-
50
- globalThis.BigNumber = utils.BigNumber;
51
-
52
- globalThis.peernet = globalThis.peernet || {};
53
- globalThis.contracts = {};
54
-
55
- const run = async (blocks) => {
56
- blocks = await Promise.all(blocks.map(block => new BlockMessage(block)));
57
- blocks = blocks.sort((a, b) => a.decoded.timestamp - b.decoded.timestamp);
58
-
59
- blocks = await Promise.all(blocks.map(block => new Promise(async (resolve, reject) => {
60
- if (globalThis.process) {
61
- const worker = child_process.fork(require$$1.join(__dirname, './transaction-worker.js'), {serialization: 'advanced'});
62
-
63
- worker.once('message', async transactions => {
64
- block.decoded.transactions = transactions;
65
- const size = block.encoded.length || block.encoded.byteLength;
66
- console.log(`loaded block: ${await block.hash} @${block.decoded.index} ${utils.formatBytes(size)}`);
67
- resolve(block);
68
- });
69
-
70
- worker.send(block.decoded.transactions);
71
- } else {
72
- const worker = new Worker('./workers/transaction-worker.js');
73
- worker.onmessage = async message => {
74
- const transactions = message.data;
75
- block.decoded.transactions = transactions;
76
- const size = block.encoded.length || block.encoded.byteLength;
77
- console.log(`loaded block: ${await block.hash} @${block.decoded.index} ${utils.formatBytes(size)}`);
78
- resolve(block);
79
- };
80
- worker.postMessage(block.decoded.transactions);
81
- }
82
- })));
83
- return blocks
84
- };
85
-
86
- const tasks = async blocks => {
87
- globalThis.peernet.codecs = {
88
- 'contract-message': {
89
- codec: parseInt('63636d', 16),
90
- hashAlg: 'keccak-256'
91
- },
92
- 'transaction-message': {
93
- codec: parseInt('746d', 16),
94
- hashAlg: 'keccak-256'
95
- },
96
- 'block-message': {
97
- codec: parseInt('626d', 16),
98
- hashAlg: 'keccak-256'
99
- }
100
- };
101
-
102
- blocks = await run(blocks);
103
- globalThis.process ? process.send(blocks) : postMessage(blocks);
104
- };
105
-
106
- if (globalThis.process) {
107
- process.on('message', tasks);
108
- } else {
109
- onmessage = message => tasks(message.data);
110
- }
111
-
112
- var blockWorker = /*#__PURE__*/Object.freeze({
113
- __proto__: null
114
- });
115
-
116
- exports.blockWorker = blockWorker;
@@ -1,35 +0,0 @@
1
- 'use strict';
2
-
3
- require('./index-f77ba3de.js');
4
- var transaction = require('./transaction-6a24c91e.js');
5
-
6
- globalThis.peernet = globalThis.peernet || {};
7
- globalThis.contracts = {};
8
-
9
-
10
- process.on('message', async (transactions) => {
11
-
12
- globalThis.peernet.codecs = {
13
- 'contract-message': {
14
- codec: parseInt('63636d', 16),
15
- hashAlg: 'keccak-256'
16
- },
17
- 'transaction-message': {
18
- codec: parseInt('746d', 16),
19
- hashAlg: 'keccak-256'
20
- },
21
- 'block-message': {
22
- codec: parseInt('626d', 16),
23
- hashAlg: 'keccak-256'
24
- }
25
- };
26
- transactions = await Promise.all(transactions.map(async message => new transaction.TransactionMessage(message)));
27
-
28
- process.send(transactions);
29
- });
30
-
31
- var transactionWorker = /*#__PURE__*/Object.freeze({
32
- __proto__: null
33
- });
34
-
35
- exports.transactionWorker = transactionWorker;
@@ -1,114 +0,0 @@
1
- import { F as FormatInterface_1 } from './index-6715242b.js';
2
- import { B as BigNumber, f as formatBytes } from './utils-d240ed61.js';
3
- import { fork } from 'child_process';
4
- import { join } from 'path';
5
-
6
- var proto = `
7
- message ValidatorMessage {
8
- required string address = 1;
9
- required string reward = 2;
10
- }
11
-
12
- message Transaction {
13
- required string hash = 1;
14
- required uint64 timestamp = 2;
15
- required string from = 3;
16
- required string to = 4;
17
- required uint64 nonce = 5;
18
- required string method = 6;
19
- repeated string params = 7;
20
- }
21
-
22
- message BlockMessage {
23
- required uint64 index = 1;
24
- required string previousHash = 3;
25
- required uint64 timestamp = 4;
26
- required uint64 reward = 5;
27
- required string fees = 6;
28
- repeated Transaction transactions = 7;
29
- repeated ValidatorMessage validators = 8;
30
- }
31
- `;
32
-
33
- class BlockMessage extends FormatInterface_1 {
34
- get keys() {
35
- return ['index', 'previousHash', 'timestamp', 'reward', 'fees', 'transactions', 'validators']
36
- }
37
-
38
- get messageName() {
39
- return 'BlockMessage'
40
- }
41
-
42
- constructor(buffer) {
43
- const name = 'block-message';
44
- super(buffer, proto, {name});
45
- }
46
- }
47
-
48
- globalThis.BigNumber = BigNumber;
49
-
50
- globalThis.peernet = globalThis.peernet || {};
51
- globalThis.contracts = {};
52
-
53
- const run = async (blocks) => {
54
- blocks = await Promise.all(blocks.map(block => new BlockMessage(block)));
55
- blocks = blocks.sort((a, b) => a.decoded.timestamp - b.decoded.timestamp);
56
-
57
- blocks = await Promise.all(blocks.map(block => new Promise(async (resolve, reject) => {
58
- if (globalThis.process) {
59
- const worker = fork(join(__dirname, './transaction-worker.js'), {serialization: 'advanced'});
60
-
61
- worker.once('message', async transactions => {
62
- block.decoded.transactions = transactions;
63
- const size = block.encoded.length || block.encoded.byteLength;
64
- console.log(`loaded block: ${await block.hash} @${block.decoded.index} ${formatBytes(size)}`);
65
- resolve(block);
66
- });
67
-
68
- worker.send(block.decoded.transactions);
69
- } else {
70
- const worker = new Worker('./workers/transaction-worker.js');
71
- worker.onmessage = async message => {
72
- const transactions = message.data;
73
- block.decoded.transactions = transactions;
74
- const size = block.encoded.length || block.encoded.byteLength;
75
- console.log(`loaded block: ${await block.hash} @${block.decoded.index} ${formatBytes(size)}`);
76
- resolve(block);
77
- };
78
- worker.postMessage(block.decoded.transactions);
79
- }
80
- })));
81
- return blocks
82
- };
83
-
84
- const tasks = async blocks => {
85
- globalThis.peernet.codecs = {
86
- 'contract-message': {
87
- codec: parseInt('63636d', 16),
88
- hashAlg: 'keccak-256'
89
- },
90
- 'transaction-message': {
91
- codec: parseInt('746d', 16),
92
- hashAlg: 'keccak-256'
93
- },
94
- 'block-message': {
95
- codec: parseInt('626d', 16),
96
- hashAlg: 'keccak-256'
97
- }
98
- };
99
-
100
- blocks = await run(blocks);
101
- globalThis.process ? process.send(blocks) : postMessage(blocks);
102
- };
103
-
104
- if (globalThis.process) {
105
- process.on('message', tasks);
106
- } else {
107
- onmessage = message => tasks(message.data);
108
- }
109
-
110
- var blockWorker = /*#__PURE__*/Object.freeze({
111
- __proto__: null
112
- });
113
-
114
- export { blockWorker as b };
@@ -1,33 +0,0 @@
1
- import './index-6715242b.js';
2
- import { T as TransactionMessage } from './transaction-e9126d7b.js';
3
-
4
- globalThis.peernet = globalThis.peernet || {};
5
- globalThis.contracts = {};
6
-
7
-
8
- process.on('message', async (transactions) => {
9
-
10
- globalThis.peernet.codecs = {
11
- 'contract-message': {
12
- codec: parseInt('63636d', 16),
13
- hashAlg: 'keccak-256'
14
- },
15
- 'transaction-message': {
16
- codec: parseInt('746d', 16),
17
- hashAlg: 'keccak-256'
18
- },
19
- 'block-message': {
20
- codec: parseInt('626d', 16),
21
- hashAlg: 'keccak-256'
22
- }
23
- };
24
- transactions = await Promise.all(transactions.map(async message => new TransactionMessage(message)));
25
-
26
- process.send(transactions);
27
- });
28
-
29
- var transactionWorker = /*#__PURE__*/Object.freeze({
30
- __proto__: null
31
- });
32
-
33
- export { transactionWorker as t };
@@ -1,116 +0,0 @@
1
- 'use strict';
2
-
3
- var codecFormatInterface = require('@leofcoin/codec-format-interface');
4
- var utils = require('./utils-def2fce8.js');
5
- var child_process = require('child_process');
6
- var path = require('path');
7
-
8
- var proto = `
9
- message ValidatorMessage {
10
- required string address = 1;
11
- required string reward = 2;
12
- }
13
-
14
- message Transaction {
15
- required string hash = 1;
16
- required uint64 timestamp = 2;
17
- required string from = 3;
18
- required string to = 4;
19
- required uint64 nonce = 5;
20
- required string method = 6;
21
- repeated string params = 7;
22
- }
23
-
24
- message BlockMessage {
25
- required uint64 index = 1;
26
- required string previousHash = 3;
27
- required uint64 timestamp = 4;
28
- required uint64 reward = 5;
29
- required string fees = 6;
30
- repeated Transaction transactions = 7;
31
- repeated ValidatorMessage validators = 8;
32
- }
33
- `;
34
-
35
- class BlockMessage extends codecFormatInterface.FormatInterface {
36
- get keys() {
37
- return ['index', 'previousHash', 'timestamp', 'reward', 'fees', 'transactions', 'validators']
38
- }
39
-
40
- get messageName() {
41
- return 'BlockMessage'
42
- }
43
-
44
- constructor(buffer) {
45
- const name = 'block-message';
46
- super(buffer, proto, {name});
47
- }
48
- }
49
-
50
- globalThis.BigNumber = utils.BigNumber;
51
-
52
- globalThis.peernet = globalThis.peernet || {};
53
- globalThis.contracts = {};
54
-
55
- const run = async (blocks) => {
56
- blocks = await Promise.all(blocks.map(block => new BlockMessage(block)));
57
- blocks = blocks.sort((a, b) => a.decoded.timestamp - b.decoded.timestamp);
58
-
59
- blocks = await Promise.all(blocks.map(block => new Promise(async (resolve, reject) => {
60
- if (globalThis.process) {
61
- const worker = child_process.fork(path.join(__dirname, './transaction-worker.js'), {serialization: 'advanced'});
62
-
63
- worker.once('message', async transactions => {
64
- block.decoded.transactions = transactions;
65
- const size = block.encoded.length || block.encoded.byteLength;
66
- console.log(`loaded block: ${await block.hash} @${block.decoded.index} ${utils.formatBytes(size)}`);
67
- resolve(block);
68
- });
69
-
70
- worker.send(block.decoded.transactions);
71
- } else {
72
- const worker = new Worker('./workers/transaction-worker.js');
73
- worker.onmessage = async message => {
74
- const transactions = message.data;
75
- block.decoded.transactions = transactions;
76
- const size = block.encoded.length || block.encoded.byteLength;
77
- console.log(`loaded block: ${await block.hash} @${block.decoded.index} ${utils.formatBytes(size)}`);
78
- resolve(block);
79
- };
80
- worker.postMessage(block.decoded.transactions);
81
- }
82
- })));
83
- return blocks
84
- };
85
-
86
- const tasks = async blocks => {
87
- globalThis.peernet.codecs = {
88
- 'contract-message': {
89
- codec: parseInt('63636d', 16),
90
- hashAlg: 'keccak-256'
91
- },
92
- 'transaction-message': {
93
- codec: parseInt('746d', 16),
94
- hashAlg: 'keccak-256'
95
- },
96
- 'block-message': {
97
- codec: parseInt('626d', 16),
98
- hashAlg: 'keccak-256'
99
- }
100
- };
101
-
102
- blocks = await run(blocks);
103
- globalThis.process ? process.send(blocks) : postMessage(blocks);
104
- };
105
-
106
- if (globalThis.process) {
107
- process.on('message', tasks);
108
- } else {
109
- onmessage = message => tasks(message.data);
110
- }
111
-
112
- var blockWorker = /*#__PURE__*/Object.freeze({
113
- __proto__: null
114
- });
115
-
116
- exports.blockWorker = blockWorker;
@@ -1,35 +0,0 @@
1
- 'use strict';
2
-
3
- require('@leofcoin/codec-format-interface');
4
- var transaction = require('./transaction-220a3a15.js');
5
-
6
- globalThis.peernet = globalThis.peernet || {};
7
- globalThis.contracts = {};
8
-
9
-
10
- process.on('message', async (transactions) => {
11
-
12
- globalThis.peernet.codecs = {
13
- 'contract-message': {
14
- codec: parseInt('63636d', 16),
15
- hashAlg: 'keccak-256'
16
- },
17
- 'transaction-message': {
18
- codec: parseInt('746d', 16),
19
- hashAlg: 'keccak-256'
20
- },
21
- 'block-message': {
22
- codec: parseInt('626d', 16),
23
- hashAlg: 'keccak-256'
24
- }
25
- };
26
- transactions = await Promise.all(transactions.map(async message => new transaction.TransactionMessage(message)));
27
-
28
- process.send(transactions);
29
- });
30
-
31
- var transactionWorker = /*#__PURE__*/Object.freeze({
32
- __proto__: null
33
- });
34
-
35
- exports.transactionWorker = transactionWorker;
@@ -1,114 +0,0 @@
1
- import { FormatInterface } from '@leofcoin/codec-format-interface';
2
- import { B as BigNumber, f as formatBytes } from './utils-96ad7b3e.js';
3
- import { fork } from 'child_process';
4
- import { join } from 'path';
5
-
6
- var proto = `
7
- message ValidatorMessage {
8
- required string address = 1;
9
- required string reward = 2;
10
- }
11
-
12
- message Transaction {
13
- required string hash = 1;
14
- required uint64 timestamp = 2;
15
- required string from = 3;
16
- required string to = 4;
17
- required uint64 nonce = 5;
18
- required string method = 6;
19
- repeated string params = 7;
20
- }
21
-
22
- message BlockMessage {
23
- required uint64 index = 1;
24
- required string previousHash = 3;
25
- required uint64 timestamp = 4;
26
- required uint64 reward = 5;
27
- required string fees = 6;
28
- repeated Transaction transactions = 7;
29
- repeated ValidatorMessage validators = 8;
30
- }
31
- `;
32
-
33
- class BlockMessage extends FormatInterface {
34
- get keys() {
35
- return ['index', 'previousHash', 'timestamp', 'reward', 'fees', 'transactions', 'validators']
36
- }
37
-
38
- get messageName() {
39
- return 'BlockMessage'
40
- }
41
-
42
- constructor(buffer) {
43
- const name = 'block-message';
44
- super(buffer, proto, {name});
45
- }
46
- }
47
-
48
- globalThis.BigNumber = BigNumber;
49
-
50
- globalThis.peernet = globalThis.peernet || {};
51
- globalThis.contracts = {};
52
-
53
- const run = async (blocks) => {
54
- blocks = await Promise.all(blocks.map(block => new BlockMessage(block)));
55
- blocks = blocks.sort((a, b) => a.decoded.timestamp - b.decoded.timestamp);
56
-
57
- blocks = await Promise.all(blocks.map(block => new Promise(async (resolve, reject) => {
58
- if (globalThis.process) {
59
- const worker = fork(join(__dirname, './transaction-worker.js'), {serialization: 'advanced'});
60
-
61
- worker.once('message', async transactions => {
62
- block.decoded.transactions = transactions;
63
- const size = block.encoded.length || block.encoded.byteLength;
64
- console.log(`loaded block: ${await block.hash} @${block.decoded.index} ${formatBytes(size)}`);
65
- resolve(block);
66
- });
67
-
68
- worker.send(block.decoded.transactions);
69
- } else {
70
- const worker = new Worker('./workers/transaction-worker.js');
71
- worker.onmessage = async message => {
72
- const transactions = message.data;
73
- block.decoded.transactions = transactions;
74
- const size = block.encoded.length || block.encoded.byteLength;
75
- console.log(`loaded block: ${await block.hash} @${block.decoded.index} ${formatBytes(size)}`);
76
- resolve(block);
77
- };
78
- worker.postMessage(block.decoded.transactions);
79
- }
80
- })));
81
- return blocks
82
- };
83
-
84
- const tasks = async blocks => {
85
- globalThis.peernet.codecs = {
86
- 'contract-message': {
87
- codec: parseInt('63636d', 16),
88
- hashAlg: 'keccak-256'
89
- },
90
- 'transaction-message': {
91
- codec: parseInt('746d', 16),
92
- hashAlg: 'keccak-256'
93
- },
94
- 'block-message': {
95
- codec: parseInt('626d', 16),
96
- hashAlg: 'keccak-256'
97
- }
98
- };
99
-
100
- blocks = await run(blocks);
101
- globalThis.process ? process.send(blocks) : postMessage(blocks);
102
- };
103
-
104
- if (globalThis.process) {
105
- process.on('message', tasks);
106
- } else {
107
- onmessage = message => tasks(message.data);
108
- }
109
-
110
- var blockWorker = /*#__PURE__*/Object.freeze({
111
- __proto__: null
112
- });
113
-
114
- export { blockWorker as b };