@leofcoin/workers 1.1.0 → 1.1.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.
- package/dist/bundle/commonjs/{block-worker-42d9ae8e.js → block-worker-81701b46.js} +2 -1
- package/dist/bundle/commonjs/block-worker.js +2 -2
- package/dist/bundle/commonjs/{machine-worker-b376daef.js → machine-worker-28ffe20b.js} +24 -19
- package/dist/bundle/commonjs/machine-worker.js +2 -2
- package/dist/bundle/commonjs/workers.js +2 -2
- package/dist/bundle/module/{block-worker-efe837c4.js → block-worker-6f72caf6.js} +2 -1
- package/dist/bundle/module/block-worker.js +2 -2
- package/dist/bundle/module/{machine-worker-a812956d.js → machine-worker-5f6457bd.js} +24 -19
- package/dist/bundle/module/machine-worker.js +2 -2
- package/dist/bundle/module/workers.js +2 -2
- package/dist/commonjs/{block-worker-d849f917.js → block-worker-9ae351ea.js} +2 -1
- package/dist/commonjs/block-worker.js +2 -1
- package/dist/commonjs/{machine-worker-481c0a4b.js → machine-worker-5e1073c1.js} +24 -19
- package/dist/commonjs/machine-worker.js +2 -1
- package/dist/commonjs/workers.js +3 -2
- package/dist/module/{block-worker-f5b28240.js → block-worker-d07e9a9f.js} +2 -1
- package/dist/module/block-worker.js +2 -1
- package/dist/module/{machine-worker-08b605fa.js → machine-worker-12c3eda2.js} +24 -19
- package/dist/module/machine-worker.js +2 -1
- package/dist/module/workers.js +3 -2
- package/package.json +1 -1
- package/src/block-worker.js +3 -2
- package/src/machine-worker.js +24 -19
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
var index = require('./index-f77ba3de.js');
|
|
4
4
|
var utils = require('./utils-6a02b156.js');
|
|
5
5
|
var child_process = require('child_process');
|
|
6
|
+
var require$$1 = require('path');
|
|
6
7
|
|
|
7
8
|
var proto = `
|
|
8
9
|
message ValidatorMessage {
|
|
@@ -57,7 +58,7 @@ const run = async (blocks) => {
|
|
|
57
58
|
|
|
58
59
|
blocks = await Promise.all(blocks.map(block => new Promise(async (resolve, reject) => {
|
|
59
60
|
if (globalThis.process) {
|
|
60
|
-
const worker = child_process.fork('./
|
|
61
|
+
const worker = child_process.fork(require$$1.join(__dirname, './transaction-worker.js'), {serialization: 'advanced'});
|
|
61
62
|
|
|
62
63
|
worker.once('message', async transactions => {
|
|
63
64
|
block.decoded.transactions = transactions;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
require('./index-f77ba3de.js');
|
|
4
|
-
require('./block-worker-
|
|
4
|
+
require('./block-worker-81701b46.js');
|
|
5
5
|
require('./utils-6a02b156.js');
|
|
6
6
|
require('child_process');
|
|
7
|
+
require('path');
|
|
7
8
|
require('stream');
|
|
8
9
|
require('events');
|
|
9
10
|
require('buffer');
|
|
10
11
|
require('util');
|
|
11
12
|
require('string_decoder/');
|
|
12
13
|
require('fs');
|
|
13
|
-
require('path');
|
|
14
14
|
require('os');
|
|
15
15
|
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
var index = require('./index-f77ba3de.js');
|
|
4
4
|
var utils = require('./utils-6a02b156.js');
|
|
5
5
|
var child_process = require('child_process');
|
|
6
|
+
var require$$1 = require('path');
|
|
6
7
|
|
|
7
8
|
var proto = `
|
|
8
9
|
message ContractMessage {
|
|
@@ -47,6 +48,7 @@ globalThis.BigNumber = utils.BigNumber;
|
|
|
47
48
|
globalThis.peernet = globalThis.peernet || {};
|
|
48
49
|
globalThis.contracts = {};
|
|
49
50
|
|
|
51
|
+
|
|
50
52
|
const get = (contract, method, params) => {
|
|
51
53
|
let result;
|
|
52
54
|
if (params?.length > 0) {
|
|
@@ -110,6 +112,22 @@ const createMessage = (sender = globalThis.peerid) => {
|
|
|
110
112
|
};
|
|
111
113
|
|
|
112
114
|
const _init = async ({ contracts, blocks, peerid })=> {
|
|
115
|
+
|
|
116
|
+
globalThis.peernet.codecs = {
|
|
117
|
+
'contract-message': {
|
|
118
|
+
codec: parseInt('63636d', 16),
|
|
119
|
+
hashAlg: 'keccak-256'
|
|
120
|
+
},
|
|
121
|
+
'transaction-message': {
|
|
122
|
+
codec: parseInt('746d', 16),
|
|
123
|
+
hashAlg: 'keccak-256'
|
|
124
|
+
},
|
|
125
|
+
'block-message': {
|
|
126
|
+
codec: parseInt('626d', 16),
|
|
127
|
+
hashAlg: 'keccak-256'
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
|
|
113
131
|
globalThis.peerid = peerid;
|
|
114
132
|
contracts = [
|
|
115
133
|
contractFactoryMessage,
|
|
@@ -124,7 +142,7 @@ const _init = async ({ contracts, blocks, peerid })=> {
|
|
|
124
142
|
return contract
|
|
125
143
|
}));
|
|
126
144
|
|
|
127
|
-
const worker = child_process.fork('./
|
|
145
|
+
const worker = child_process.fork(require$$1.join(__dirname, './block-worker.js'), {serialization: 'advanced'});
|
|
128
146
|
// worker.on('message')
|
|
129
147
|
worker.once('message', async (blocks) => {
|
|
130
148
|
for (const block of blocks) {
|
|
@@ -145,26 +163,13 @@ const _init = async ({ contracts, blocks, peerid })=> {
|
|
|
145
163
|
};
|
|
146
164
|
|
|
147
165
|
const tasks = async (e) => {
|
|
148
|
-
|
|
149
|
-
'contract-message': {
|
|
150
|
-
codec: parseInt('63636d', 16),
|
|
151
|
-
hashAlg: 'keccak-256'
|
|
152
|
-
},
|
|
153
|
-
'transaction-message': {
|
|
154
|
-
codec: parseInt('746d', 16),
|
|
155
|
-
hashAlg: 'keccak-256'
|
|
156
|
-
},
|
|
157
|
-
'block-message': {
|
|
158
|
-
codec: parseInt('626d', 16),
|
|
159
|
-
hashAlg: 'keccak-256'
|
|
160
|
-
}
|
|
161
|
-
};
|
|
166
|
+
const id = e.id;
|
|
162
167
|
if (e.type === 'init') await _init(e.input);
|
|
163
168
|
if (e.type === 'get') {
|
|
164
169
|
const value = await get(e.input.contract, e.input.method, e.input.params);
|
|
165
170
|
process.send({
|
|
166
171
|
type: 'response',
|
|
167
|
-
id
|
|
172
|
+
id,
|
|
168
173
|
value
|
|
169
174
|
});
|
|
170
175
|
}
|
|
@@ -173,14 +178,14 @@ const tasks = async (e) => {
|
|
|
173
178
|
const value = await execute(e.input.contract, e.input.method, e.input.params);
|
|
174
179
|
process.send({
|
|
175
180
|
type: 'response',
|
|
176
|
-
id
|
|
181
|
+
id,
|
|
177
182
|
value
|
|
178
183
|
});
|
|
179
184
|
} catch(e) {
|
|
180
185
|
process.send({
|
|
181
186
|
type: 'executionError',
|
|
182
|
-
message: e,
|
|
183
|
-
id
|
|
187
|
+
message: e.message,
|
|
188
|
+
id
|
|
184
189
|
|
|
185
190
|
});
|
|
186
191
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
require('./machine-worker-
|
|
3
|
+
require('./machine-worker-28ffe20b.js');
|
|
4
4
|
require('./index-f77ba3de.js');
|
|
5
5
|
require('./utils-6a02b156.js');
|
|
6
6
|
require('child_process');
|
|
7
|
+
require('path');
|
|
7
8
|
require('stream');
|
|
8
9
|
require('events');
|
|
9
10
|
require('buffer');
|
|
10
11
|
require('util');
|
|
11
12
|
require('string_decoder/');
|
|
12
13
|
require('fs');
|
|
13
|
-
require('path');
|
|
14
14
|
require('os');
|
|
15
15
|
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var transactionWorker = require('./transaction-worker-90623101.js');
|
|
6
|
-
var blockWorker = require('./block-worker-
|
|
6
|
+
var blockWorker = require('./block-worker-81701b46.js');
|
|
7
7
|
var poolWorker = require('./pool-worker-61189fde.js');
|
|
8
|
-
var machineWorker = require('./machine-worker-
|
|
8
|
+
var machineWorker = require('./machine-worker-28ffe20b.js');
|
|
9
9
|
require('./index-f77ba3de.js');
|
|
10
10
|
require('stream');
|
|
11
11
|
require('events');
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { F as FormatInterface_1 } from './index-6715242b.js';
|
|
2
2
|
import { B as BigNumber, f as formatBytes } from './utils-d240ed61.js';
|
|
3
3
|
import { fork } from 'child_process';
|
|
4
|
+
import { join } from 'path';
|
|
4
5
|
|
|
5
6
|
var proto = `
|
|
6
7
|
message ValidatorMessage {
|
|
@@ -55,7 +56,7 @@ const run = async (blocks) => {
|
|
|
55
56
|
|
|
56
57
|
blocks = await Promise.all(blocks.map(block => new Promise(async (resolve, reject) => {
|
|
57
58
|
if (globalThis.process) {
|
|
58
|
-
const worker = fork('./
|
|
59
|
+
const worker = fork(join(__dirname, './transaction-worker.js'), {serialization: 'advanced'});
|
|
59
60
|
|
|
60
61
|
worker.once('message', async transactions => {
|
|
61
62
|
block.decoded.transactions = transactions;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import './index-6715242b.js';
|
|
2
|
-
import './block-worker-
|
|
2
|
+
import './block-worker-6f72caf6.js';
|
|
3
3
|
import './utils-d240ed61.js';
|
|
4
4
|
import 'child_process';
|
|
5
|
+
import 'path';
|
|
5
6
|
import 'stream';
|
|
6
7
|
import 'events';
|
|
7
8
|
import 'buffer';
|
|
8
9
|
import 'util';
|
|
9
10
|
import 'string_decoder/';
|
|
10
11
|
import 'fs';
|
|
11
|
-
import 'path';
|
|
12
12
|
import 'os';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { F as FormatInterface_1 } from './index-6715242b.js';
|
|
2
2
|
import { B as BigNumber, f as formatBytes } from './utils-d240ed61.js';
|
|
3
3
|
import { fork } from 'child_process';
|
|
4
|
+
import { join } from 'path';
|
|
4
5
|
|
|
5
6
|
var proto = `
|
|
6
7
|
message ContractMessage {
|
|
@@ -45,6 +46,7 @@ globalThis.BigNumber = BigNumber;
|
|
|
45
46
|
globalThis.peernet = globalThis.peernet || {};
|
|
46
47
|
globalThis.contracts = {};
|
|
47
48
|
|
|
49
|
+
|
|
48
50
|
const get = (contract, method, params) => {
|
|
49
51
|
let result;
|
|
50
52
|
if (params?.length > 0) {
|
|
@@ -108,6 +110,22 @@ const createMessage = (sender = globalThis.peerid) => {
|
|
|
108
110
|
};
|
|
109
111
|
|
|
110
112
|
const _init = async ({ contracts, blocks, peerid })=> {
|
|
113
|
+
|
|
114
|
+
globalThis.peernet.codecs = {
|
|
115
|
+
'contract-message': {
|
|
116
|
+
codec: parseInt('63636d', 16),
|
|
117
|
+
hashAlg: 'keccak-256'
|
|
118
|
+
},
|
|
119
|
+
'transaction-message': {
|
|
120
|
+
codec: parseInt('746d', 16),
|
|
121
|
+
hashAlg: 'keccak-256'
|
|
122
|
+
},
|
|
123
|
+
'block-message': {
|
|
124
|
+
codec: parseInt('626d', 16),
|
|
125
|
+
hashAlg: 'keccak-256'
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
|
|
111
129
|
globalThis.peerid = peerid;
|
|
112
130
|
contracts = [
|
|
113
131
|
contractFactoryMessage,
|
|
@@ -122,7 +140,7 @@ const _init = async ({ contracts, blocks, peerid })=> {
|
|
|
122
140
|
return contract
|
|
123
141
|
}));
|
|
124
142
|
|
|
125
|
-
const worker = fork('./
|
|
143
|
+
const worker = fork(join(__dirname, './block-worker.js'), {serialization: 'advanced'});
|
|
126
144
|
// worker.on('message')
|
|
127
145
|
worker.once('message', async (blocks) => {
|
|
128
146
|
for (const block of blocks) {
|
|
@@ -143,26 +161,13 @@ const _init = async ({ contracts, blocks, peerid })=> {
|
|
|
143
161
|
};
|
|
144
162
|
|
|
145
163
|
const tasks = async (e) => {
|
|
146
|
-
|
|
147
|
-
'contract-message': {
|
|
148
|
-
codec: parseInt('63636d', 16),
|
|
149
|
-
hashAlg: 'keccak-256'
|
|
150
|
-
},
|
|
151
|
-
'transaction-message': {
|
|
152
|
-
codec: parseInt('746d', 16),
|
|
153
|
-
hashAlg: 'keccak-256'
|
|
154
|
-
},
|
|
155
|
-
'block-message': {
|
|
156
|
-
codec: parseInt('626d', 16),
|
|
157
|
-
hashAlg: 'keccak-256'
|
|
158
|
-
}
|
|
159
|
-
};
|
|
164
|
+
const id = e.id;
|
|
160
165
|
if (e.type === 'init') await _init(e.input);
|
|
161
166
|
if (e.type === 'get') {
|
|
162
167
|
const value = await get(e.input.contract, e.input.method, e.input.params);
|
|
163
168
|
process.send({
|
|
164
169
|
type: 'response',
|
|
165
|
-
id
|
|
170
|
+
id,
|
|
166
171
|
value
|
|
167
172
|
});
|
|
168
173
|
}
|
|
@@ -171,14 +176,14 @@ const tasks = async (e) => {
|
|
|
171
176
|
const value = await execute(e.input.contract, e.input.method, e.input.params);
|
|
172
177
|
process.send({
|
|
173
178
|
type: 'response',
|
|
174
|
-
id
|
|
179
|
+
id,
|
|
175
180
|
value
|
|
176
181
|
});
|
|
177
182
|
} catch(e) {
|
|
178
183
|
process.send({
|
|
179
184
|
type: 'executionError',
|
|
180
|
-
message: e,
|
|
181
|
-
id
|
|
185
|
+
message: e.message,
|
|
186
|
+
id
|
|
182
187
|
|
|
183
188
|
});
|
|
184
189
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import './machine-worker-
|
|
1
|
+
import './machine-worker-5f6457bd.js';
|
|
2
2
|
import './index-6715242b.js';
|
|
3
3
|
import './utils-d240ed61.js';
|
|
4
4
|
import 'child_process';
|
|
5
|
+
import 'path';
|
|
5
6
|
import 'stream';
|
|
6
7
|
import 'events';
|
|
7
8
|
import 'buffer';
|
|
8
9
|
import 'util';
|
|
9
10
|
import 'string_decoder/';
|
|
10
11
|
import 'fs';
|
|
11
|
-
import 'path';
|
|
12
12
|
import 'os';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as transactionWorker } from './transaction-worker-8afddd7e.js';
|
|
2
|
-
import { b as blockWorker } from './block-worker-
|
|
2
|
+
import { b as blockWorker } from './block-worker-6f72caf6.js';
|
|
3
3
|
import { p as poolWorker } from './pool-worker-012d12c9.js';
|
|
4
|
-
import { m as machineWorker } from './machine-worker-
|
|
4
|
+
import { m as machineWorker } from './machine-worker-5f6457bd.js';
|
|
5
5
|
import './index-6715242b.js';
|
|
6
6
|
import 'stream';
|
|
7
7
|
import 'events';
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
var codecFormatInterface = require('@leofcoin/codec-format-interface');
|
|
4
4
|
var utils = require('./utils-def2fce8.js');
|
|
5
5
|
var child_process = require('child_process');
|
|
6
|
+
var path = require('path');
|
|
6
7
|
|
|
7
8
|
var proto = `
|
|
8
9
|
message ValidatorMessage {
|
|
@@ -57,7 +58,7 @@ const run = async (blocks) => {
|
|
|
57
58
|
|
|
58
59
|
blocks = await Promise.all(blocks.map(block => new Promise(async (resolve, reject) => {
|
|
59
60
|
if (globalThis.process) {
|
|
60
|
-
const worker = child_process.fork('./
|
|
61
|
+
const worker = child_process.fork(path.join(__dirname, './transaction-worker.js'), {serialization: 'advanced'});
|
|
61
62
|
|
|
62
63
|
worker.once('message', async transactions => {
|
|
63
64
|
block.decoded.transactions = transactions;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
require('@leofcoin/codec-format-interface');
|
|
4
|
-
require('./block-worker-
|
|
4
|
+
require('./block-worker-9ae351ea.js');
|
|
5
5
|
require('./utils-def2fce8.js');
|
|
6
6
|
require('child_process');
|
|
7
|
+
require('path');
|
|
7
8
|
require('bn.js');
|
|
8
9
|
require('@ethersproject/bytes');
|
|
9
10
|
require('@ethersproject/logger');
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
var codecFormatInterface = require('@leofcoin/codec-format-interface');
|
|
4
4
|
var utils = require('./utils-def2fce8.js');
|
|
5
5
|
var child_process = require('child_process');
|
|
6
|
+
var path = require('path');
|
|
6
7
|
|
|
7
8
|
var proto = `
|
|
8
9
|
message ContractMessage {
|
|
@@ -47,6 +48,7 @@ globalThis.BigNumber = utils.BigNumber;
|
|
|
47
48
|
globalThis.peernet = globalThis.peernet || {};
|
|
48
49
|
globalThis.contracts = {};
|
|
49
50
|
|
|
51
|
+
|
|
50
52
|
const get = (contract, method, params) => {
|
|
51
53
|
let result;
|
|
52
54
|
if (params?.length > 0) {
|
|
@@ -110,6 +112,22 @@ const createMessage = (sender = globalThis.peerid) => {
|
|
|
110
112
|
};
|
|
111
113
|
|
|
112
114
|
const _init = async ({ contracts, blocks, peerid })=> {
|
|
115
|
+
|
|
116
|
+
globalThis.peernet.codecs = {
|
|
117
|
+
'contract-message': {
|
|
118
|
+
codec: parseInt('63636d', 16),
|
|
119
|
+
hashAlg: 'keccak-256'
|
|
120
|
+
},
|
|
121
|
+
'transaction-message': {
|
|
122
|
+
codec: parseInt('746d', 16),
|
|
123
|
+
hashAlg: 'keccak-256'
|
|
124
|
+
},
|
|
125
|
+
'block-message': {
|
|
126
|
+
codec: parseInt('626d', 16),
|
|
127
|
+
hashAlg: 'keccak-256'
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
|
|
113
131
|
globalThis.peerid = peerid;
|
|
114
132
|
contracts = [
|
|
115
133
|
contractFactoryMessage,
|
|
@@ -124,7 +142,7 @@ const _init = async ({ contracts, blocks, peerid })=> {
|
|
|
124
142
|
return contract
|
|
125
143
|
}));
|
|
126
144
|
|
|
127
|
-
const worker = child_process.fork('./
|
|
145
|
+
const worker = child_process.fork(path.join(__dirname, './block-worker.js'), {serialization: 'advanced'});
|
|
128
146
|
// worker.on('message')
|
|
129
147
|
worker.once('message', async (blocks) => {
|
|
130
148
|
for (const block of blocks) {
|
|
@@ -145,26 +163,13 @@ const _init = async ({ contracts, blocks, peerid })=> {
|
|
|
145
163
|
};
|
|
146
164
|
|
|
147
165
|
const tasks = async (e) => {
|
|
148
|
-
|
|
149
|
-
'contract-message': {
|
|
150
|
-
codec: parseInt('63636d', 16),
|
|
151
|
-
hashAlg: 'keccak-256'
|
|
152
|
-
},
|
|
153
|
-
'transaction-message': {
|
|
154
|
-
codec: parseInt('746d', 16),
|
|
155
|
-
hashAlg: 'keccak-256'
|
|
156
|
-
},
|
|
157
|
-
'block-message': {
|
|
158
|
-
codec: parseInt('626d', 16),
|
|
159
|
-
hashAlg: 'keccak-256'
|
|
160
|
-
}
|
|
161
|
-
};
|
|
166
|
+
const id = e.id;
|
|
162
167
|
if (e.type === 'init') await _init(e.input);
|
|
163
168
|
if (e.type === 'get') {
|
|
164
169
|
const value = await get(e.input.contract, e.input.method, e.input.params);
|
|
165
170
|
process.send({
|
|
166
171
|
type: 'response',
|
|
167
|
-
id
|
|
172
|
+
id,
|
|
168
173
|
value
|
|
169
174
|
});
|
|
170
175
|
}
|
|
@@ -173,14 +178,14 @@ const tasks = async (e) => {
|
|
|
173
178
|
const value = await execute(e.input.contract, e.input.method, e.input.params);
|
|
174
179
|
process.send({
|
|
175
180
|
type: 'response',
|
|
176
|
-
id
|
|
181
|
+
id,
|
|
177
182
|
value
|
|
178
183
|
});
|
|
179
184
|
} catch(e) {
|
|
180
185
|
process.send({
|
|
181
186
|
type: 'executionError',
|
|
182
|
-
message: e,
|
|
183
|
-
id
|
|
187
|
+
message: e.message,
|
|
188
|
+
id
|
|
184
189
|
|
|
185
190
|
});
|
|
186
191
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
require('./machine-worker-
|
|
3
|
+
require('./machine-worker-5e1073c1.js');
|
|
4
4
|
require('@leofcoin/codec-format-interface');
|
|
5
5
|
require('./utils-def2fce8.js');
|
|
6
6
|
require('child_process');
|
|
7
|
+
require('path');
|
|
7
8
|
require('bn.js');
|
|
8
9
|
require('@ethersproject/bytes');
|
|
9
10
|
require('@ethersproject/logger');
|
package/dist/commonjs/workers.js
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var transactionWorker = require('./transaction-worker-02476daf.js');
|
|
6
|
-
var blockWorker = require('./block-worker-
|
|
6
|
+
var blockWorker = require('./block-worker-9ae351ea.js');
|
|
7
7
|
var poolWorker = require('./pool-worker-3d581327.js');
|
|
8
|
-
var machineWorker = require('./machine-worker-
|
|
8
|
+
var machineWorker = require('./machine-worker-5e1073c1.js');
|
|
9
9
|
require('@leofcoin/codec-format-interface');
|
|
10
10
|
require('./transaction-220a3a15.js');
|
|
11
11
|
require('./utils-def2fce8.js');
|
|
@@ -14,6 +14,7 @@ require('@ethersproject/bytes');
|
|
|
14
14
|
require('@ethersproject/logger');
|
|
15
15
|
require('@ethersproject/bignumber');
|
|
16
16
|
require('child_process');
|
|
17
|
+
require('path');
|
|
17
18
|
|
|
18
19
|
const TransactionWorker = transactionWorker.transactionWorker;
|
|
19
20
|
const BlockWorker = blockWorker.blockWorker;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { FormatInterface } from '@leofcoin/codec-format-interface';
|
|
2
2
|
import { B as BigNumber, f as formatBytes } from './utils-96ad7b3e.js';
|
|
3
3
|
import { fork } from 'child_process';
|
|
4
|
+
import { join } from 'path';
|
|
4
5
|
|
|
5
6
|
var proto = `
|
|
6
7
|
message ValidatorMessage {
|
|
@@ -55,7 +56,7 @@ const run = async (blocks) => {
|
|
|
55
56
|
|
|
56
57
|
blocks = await Promise.all(blocks.map(block => new Promise(async (resolve, reject) => {
|
|
57
58
|
if (globalThis.process) {
|
|
58
|
-
const worker = fork('./
|
|
59
|
+
const worker = fork(join(__dirname, './transaction-worker.js'), {serialization: 'advanced'});
|
|
59
60
|
|
|
60
61
|
worker.once('message', async transactions => {
|
|
61
62
|
block.decoded.transactions = transactions;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import '@leofcoin/codec-format-interface';
|
|
2
|
-
import './block-worker-
|
|
2
|
+
import './block-worker-d07e9a9f.js';
|
|
3
3
|
import './utils-96ad7b3e.js';
|
|
4
4
|
import 'child_process';
|
|
5
|
+
import 'path';
|
|
5
6
|
import 'bn.js';
|
|
6
7
|
import '@ethersproject/bytes';
|
|
7
8
|
import '@ethersproject/logger';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { FormatInterface } from '@leofcoin/codec-format-interface';
|
|
2
2
|
import { B as BigNumber, f as formatBytes } from './utils-96ad7b3e.js';
|
|
3
3
|
import { fork } from 'child_process';
|
|
4
|
+
import { join } from 'path';
|
|
4
5
|
|
|
5
6
|
var proto = `
|
|
6
7
|
message ContractMessage {
|
|
@@ -45,6 +46,7 @@ globalThis.BigNumber = BigNumber;
|
|
|
45
46
|
globalThis.peernet = globalThis.peernet || {};
|
|
46
47
|
globalThis.contracts = {};
|
|
47
48
|
|
|
49
|
+
|
|
48
50
|
const get = (contract, method, params) => {
|
|
49
51
|
let result;
|
|
50
52
|
if (params?.length > 0) {
|
|
@@ -108,6 +110,22 @@ const createMessage = (sender = globalThis.peerid) => {
|
|
|
108
110
|
};
|
|
109
111
|
|
|
110
112
|
const _init = async ({ contracts, blocks, peerid })=> {
|
|
113
|
+
|
|
114
|
+
globalThis.peernet.codecs = {
|
|
115
|
+
'contract-message': {
|
|
116
|
+
codec: parseInt('63636d', 16),
|
|
117
|
+
hashAlg: 'keccak-256'
|
|
118
|
+
},
|
|
119
|
+
'transaction-message': {
|
|
120
|
+
codec: parseInt('746d', 16),
|
|
121
|
+
hashAlg: 'keccak-256'
|
|
122
|
+
},
|
|
123
|
+
'block-message': {
|
|
124
|
+
codec: parseInt('626d', 16),
|
|
125
|
+
hashAlg: 'keccak-256'
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
|
|
111
129
|
globalThis.peerid = peerid;
|
|
112
130
|
contracts = [
|
|
113
131
|
contractFactoryMessage,
|
|
@@ -122,7 +140,7 @@ const _init = async ({ contracts, blocks, peerid })=> {
|
|
|
122
140
|
return contract
|
|
123
141
|
}));
|
|
124
142
|
|
|
125
|
-
const worker = fork('./
|
|
143
|
+
const worker = fork(join(__dirname, './block-worker.js'), {serialization: 'advanced'});
|
|
126
144
|
// worker.on('message')
|
|
127
145
|
worker.once('message', async (blocks) => {
|
|
128
146
|
for (const block of blocks) {
|
|
@@ -143,26 +161,13 @@ const _init = async ({ contracts, blocks, peerid })=> {
|
|
|
143
161
|
};
|
|
144
162
|
|
|
145
163
|
const tasks = async (e) => {
|
|
146
|
-
|
|
147
|
-
'contract-message': {
|
|
148
|
-
codec: parseInt('63636d', 16),
|
|
149
|
-
hashAlg: 'keccak-256'
|
|
150
|
-
},
|
|
151
|
-
'transaction-message': {
|
|
152
|
-
codec: parseInt('746d', 16),
|
|
153
|
-
hashAlg: 'keccak-256'
|
|
154
|
-
},
|
|
155
|
-
'block-message': {
|
|
156
|
-
codec: parseInt('626d', 16),
|
|
157
|
-
hashAlg: 'keccak-256'
|
|
158
|
-
}
|
|
159
|
-
};
|
|
164
|
+
const id = e.id;
|
|
160
165
|
if (e.type === 'init') await _init(e.input);
|
|
161
166
|
if (e.type === 'get') {
|
|
162
167
|
const value = await get(e.input.contract, e.input.method, e.input.params);
|
|
163
168
|
process.send({
|
|
164
169
|
type: 'response',
|
|
165
|
-
id
|
|
170
|
+
id,
|
|
166
171
|
value
|
|
167
172
|
});
|
|
168
173
|
}
|
|
@@ -171,14 +176,14 @@ const tasks = async (e) => {
|
|
|
171
176
|
const value = await execute(e.input.contract, e.input.method, e.input.params);
|
|
172
177
|
process.send({
|
|
173
178
|
type: 'response',
|
|
174
|
-
id
|
|
179
|
+
id,
|
|
175
180
|
value
|
|
176
181
|
});
|
|
177
182
|
} catch(e) {
|
|
178
183
|
process.send({
|
|
179
184
|
type: 'executionError',
|
|
180
|
-
message: e,
|
|
181
|
-
id
|
|
185
|
+
message: e.message,
|
|
186
|
+
id
|
|
182
187
|
|
|
183
188
|
});
|
|
184
189
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import './machine-worker-
|
|
1
|
+
import './machine-worker-12c3eda2.js';
|
|
2
2
|
import '@leofcoin/codec-format-interface';
|
|
3
3
|
import './utils-96ad7b3e.js';
|
|
4
4
|
import 'child_process';
|
|
5
|
+
import 'path';
|
|
5
6
|
import 'bn.js';
|
|
6
7
|
import '@ethersproject/bytes';
|
|
7
8
|
import '@ethersproject/logger';
|
package/dist/module/workers.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as transactionWorker } from './transaction-worker-0f96397e.js';
|
|
2
|
-
import { b as blockWorker } from './block-worker-
|
|
2
|
+
import { b as blockWorker } from './block-worker-d07e9a9f.js';
|
|
3
3
|
import { p as poolWorker } from './pool-worker-8d3369b4.js';
|
|
4
|
-
import { m as machineWorker } from './machine-worker-
|
|
4
|
+
import { m as machineWorker } from './machine-worker-12c3eda2.js';
|
|
5
5
|
import '@leofcoin/codec-format-interface';
|
|
6
6
|
import './transaction-d06dc6c4.js';
|
|
7
7
|
import './utils-96ad7b3e.js';
|
|
@@ -10,6 +10,7 @@ import '@ethersproject/bytes';
|
|
|
10
10
|
import '@ethersproject/logger';
|
|
11
11
|
import '@ethersproject/bignumber';
|
|
12
12
|
import 'child_process';
|
|
13
|
+
import 'path';
|
|
13
14
|
|
|
14
15
|
const TransactionWorker = transactionWorker;
|
|
15
16
|
const BlockWorker = blockWorker;
|
package/package.json
CHANGED
package/src/block-worker.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { BlockMessage } from '../../messages/src/messages'
|
|
1
|
+
import { BlockMessage, ContractMessage, TransactionMessage } from '../../messages/src/messages'
|
|
2
2
|
import { formatBytes, BigNumber } from '../../utils/src/utils'
|
|
3
3
|
import bytecodes from '../../lib/src/bytecodes.json'
|
|
4
4
|
import { fork } from 'child_process'
|
|
5
|
+
import { join } from 'path'
|
|
5
6
|
|
|
6
7
|
const contractFactoryMessage = bytecodes.contractFactory
|
|
7
8
|
const nativeTokenMessage = bytecodes.nativeToken
|
|
@@ -19,7 +20,7 @@ const run = async (blocks) => {
|
|
|
19
20
|
|
|
20
21
|
blocks = await Promise.all(blocks.map(block => new Promise(async (resolve, reject) => {
|
|
21
22
|
if (globalThis.process) {
|
|
22
|
-
const worker = fork('./
|
|
23
|
+
const worker = fork(join(__dirname, './transaction-worker.js'), {serialization: 'advanced'})
|
|
23
24
|
|
|
24
25
|
worker.once('message', async transactions => {
|
|
25
26
|
block.decoded.transactions = transactions
|
package/src/machine-worker.js
CHANGED
|
@@ -2,6 +2,7 @@ import { BlockMessage, ContractMessage, TransactionMessage } from './../../messa
|
|
|
2
2
|
import { formatBytes, BigNumber } from './../../utils/src/utils'
|
|
3
3
|
import bytecodes from './../../lib/src/bytecodes.json'
|
|
4
4
|
import { fork } from 'child_process'
|
|
5
|
+
import { join } from 'path'
|
|
5
6
|
const contractFactoryMessage = bytecodes.contractFactory
|
|
6
7
|
const nativeTokenMessage = bytecodes.nativeToken
|
|
7
8
|
const nameServiceMessage = bytecodes.nameService
|
|
@@ -12,6 +13,7 @@ globalThis.BigNumber = BigNumber
|
|
|
12
13
|
globalThis.peernet = globalThis.peernet || {}
|
|
13
14
|
globalThis.contracts = {}
|
|
14
15
|
|
|
16
|
+
|
|
15
17
|
const get = (contract, method, params) => {
|
|
16
18
|
let result
|
|
17
19
|
if (params?.length > 0) {
|
|
@@ -75,6 +77,22 @@ const createMessage = (sender = globalThis.peerid) => {
|
|
|
75
77
|
}
|
|
76
78
|
|
|
77
79
|
const _init = async ({ contracts, blocks, peerid })=> {
|
|
80
|
+
|
|
81
|
+
globalThis.peernet.codecs = {
|
|
82
|
+
'contract-message': {
|
|
83
|
+
codec: parseInt('63636d', 16),
|
|
84
|
+
hashAlg: 'keccak-256'
|
|
85
|
+
},
|
|
86
|
+
'transaction-message': {
|
|
87
|
+
codec: parseInt('746d', 16),
|
|
88
|
+
hashAlg: 'keccak-256'
|
|
89
|
+
},
|
|
90
|
+
'block-message': {
|
|
91
|
+
codec: parseInt('626d', 16),
|
|
92
|
+
hashAlg: 'keccak-256'
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
78
96
|
globalThis.peerid = peerid
|
|
79
97
|
contracts = [
|
|
80
98
|
contractFactoryMessage,
|
|
@@ -89,7 +107,7 @@ const _init = async ({ contracts, blocks, peerid })=> {
|
|
|
89
107
|
return contract
|
|
90
108
|
}))
|
|
91
109
|
|
|
92
|
-
const worker = fork('./
|
|
110
|
+
const worker = fork(join(__dirname, './block-worker.js'), {serialization: 'advanced'})
|
|
93
111
|
// worker.on('message')
|
|
94
112
|
worker.once('message', async (blocks) => {
|
|
95
113
|
for (const block of blocks) {
|
|
@@ -110,26 +128,13 @@ const _init = async ({ contracts, blocks, peerid })=> {
|
|
|
110
128
|
}
|
|
111
129
|
|
|
112
130
|
const tasks = async (e) => {
|
|
113
|
-
|
|
114
|
-
'contract-message': {
|
|
115
|
-
codec: parseInt('63636d', 16),
|
|
116
|
-
hashAlg: 'keccak-256'
|
|
117
|
-
},
|
|
118
|
-
'transaction-message': {
|
|
119
|
-
codec: parseInt('746d', 16),
|
|
120
|
-
hashAlg: 'keccak-256'
|
|
121
|
-
},
|
|
122
|
-
'block-message': {
|
|
123
|
-
codec: parseInt('626d', 16),
|
|
124
|
-
hashAlg: 'keccak-256'
|
|
125
|
-
}
|
|
126
|
-
}
|
|
131
|
+
const id = e.id
|
|
127
132
|
if (e.type === 'init') await _init(e.input)
|
|
128
133
|
if (e.type === 'get') {
|
|
129
134
|
const value = await get(e.input.contract, e.input.method, e.input.params)
|
|
130
135
|
process.send({
|
|
131
136
|
type: 'response',
|
|
132
|
-
id
|
|
137
|
+
id,
|
|
133
138
|
value
|
|
134
139
|
})
|
|
135
140
|
}
|
|
@@ -138,14 +143,14 @@ const tasks = async (e) => {
|
|
|
138
143
|
const value = await execute(e.input.contract, e.input.method, e.input.params)
|
|
139
144
|
process.send({
|
|
140
145
|
type: 'response',
|
|
141
|
-
id
|
|
146
|
+
id,
|
|
142
147
|
value
|
|
143
148
|
})
|
|
144
149
|
} catch(e) {
|
|
145
150
|
process.send({
|
|
146
151
|
type: 'executionError',
|
|
147
|
-
message: e,
|
|
148
|
-
id
|
|
152
|
+
message: e.message,
|
|
153
|
+
id
|
|
149
154
|
|
|
150
155
|
})
|
|
151
156
|
}
|