@leofcoin/workers 1.2.0 → 1.2.2
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/{machine-worker-13071997.js → machine-worker-e96e3082.js} +2 -2
- package/dist/bundle/commonjs/machine-worker.js +1 -1
- package/dist/bundle/commonjs/workers.js +1 -1
- package/dist/bundle/module/{machine-worker-421324a1.js → machine-worker-e3020b69.js} +2 -2
- package/dist/bundle/module/machine-worker.js +1 -1
- package/dist/bundle/module/workers.js +1 -1
- package/dist/commonjs/{machine-worker-696e3b91.js → machine-worker-16dad57f.js} +2 -2
- package/dist/commonjs/machine-worker.js +1 -1
- package/dist/commonjs/workers.js +1 -1
- package/dist/module/{machine-worker-e7d98549.js → machine-worker-a2897101.js} +2 -2
- package/dist/module/machine-worker.js +1 -1
- package/dist/module/workers.js +1 -1
- package/package.json +1 -1
- package/src/machine-worker.js +26 -28
|
@@ -142,7 +142,7 @@ const _init = async ({ contracts, blocks, peerid })=> {
|
|
|
142
142
|
return contract
|
|
143
143
|
}));
|
|
144
144
|
|
|
145
|
-
const _worker = new worker$1.EasyWorker(require$$1.join(__dirname, './block-worker.js'), {serialization: 'advanced'});
|
|
145
|
+
const _worker = await new worker$1.EasyWorker(require$$1.join(__dirname, './block-worker.js'), {serialization: 'advanced', type: 'module' });
|
|
146
146
|
// worker.on('message')
|
|
147
147
|
_worker.once('message', async (blocks) => {
|
|
148
148
|
for (const block of blocks) {
|
|
@@ -169,7 +169,7 @@ const _init = async ({ contracts, blocks, peerid })=> {
|
|
|
169
169
|
|
|
170
170
|
|
|
171
171
|
});
|
|
172
|
-
worker.
|
|
172
|
+
worker.postMessage(blocks);
|
|
173
173
|
};
|
|
174
174
|
|
|
175
175
|
const tasks = async (e) => {
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var transactionWorker = require('./transaction-worker-176a5aaa.js');
|
|
6
6
|
var blockWorker = require('./block-worker-21ad8152.js');
|
|
7
7
|
var poolWorker = require('./pool-worker-f450eeff.js');
|
|
8
|
-
var machineWorker = require('./machine-worker-
|
|
8
|
+
var machineWorker = require('./machine-worker-e96e3082.js');
|
|
9
9
|
require('./worker-6ace445f.js');
|
|
10
10
|
require('stream');
|
|
11
11
|
require('events');
|
|
@@ -140,7 +140,7 @@ const _init = async ({ contracts, blocks, peerid })=> {
|
|
|
140
140
|
return contract
|
|
141
141
|
}));
|
|
142
142
|
|
|
143
|
-
const _worker = new EasyWorker(join(__dirname, './block-worker.js'), {serialization: 'advanced'});
|
|
143
|
+
const _worker = await new EasyWorker(join(__dirname, './block-worker.js'), {serialization: 'advanced', type: 'module' });
|
|
144
144
|
// worker.on('message')
|
|
145
145
|
_worker.once('message', async (blocks) => {
|
|
146
146
|
for (const block of blocks) {
|
|
@@ -167,7 +167,7 @@ const _init = async ({ contracts, blocks, peerid })=> {
|
|
|
167
167
|
|
|
168
168
|
|
|
169
169
|
});
|
|
170
|
-
worker.
|
|
170
|
+
worker.postMessage(blocks);
|
|
171
171
|
};
|
|
172
172
|
|
|
173
173
|
const tasks = async (e) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as transactionWorker } from './transaction-worker-548cd200.js';
|
|
2
2
|
import { b as blockWorker } from './block-worker-414860e0.js';
|
|
3
3
|
import { p as poolWorker } from './pool-worker-0d927e3c.js';
|
|
4
|
-
import { m as machineWorker } from './machine-worker-
|
|
4
|
+
import { m as machineWorker } from './machine-worker-e3020b69.js';
|
|
5
5
|
import './worker-def77c26.js';
|
|
6
6
|
import 'stream';
|
|
7
7
|
import 'events';
|
|
@@ -147,7 +147,7 @@ const _init = async ({ contracts, blocks, peerid })=> {
|
|
|
147
147
|
return contract
|
|
148
148
|
}));
|
|
149
149
|
|
|
150
|
-
const _worker = new EasyWorker__default["default"](path.join(__dirname, './block-worker.js'), {serialization: 'advanced'});
|
|
150
|
+
const _worker = await new EasyWorker__default["default"](path.join(__dirname, './block-worker.js'), {serialization: 'advanced', type: 'module' });
|
|
151
151
|
// worker.on('message')
|
|
152
152
|
_worker.once('message', async (blocks) => {
|
|
153
153
|
for (const block of blocks) {
|
|
@@ -174,7 +174,7 @@ const _init = async ({ contracts, blocks, peerid })=> {
|
|
|
174
174
|
|
|
175
175
|
|
|
176
176
|
});
|
|
177
|
-
worker.
|
|
177
|
+
worker.postMessage(blocks);
|
|
178
178
|
};
|
|
179
179
|
|
|
180
180
|
const tasks = async (e) => {
|
package/dist/commonjs/workers.js
CHANGED
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var transactionWorker = require('./transaction-worker-8eecc7a1.js');
|
|
6
6
|
var blockWorker = require('./block-worker-60e4cfa3.js');
|
|
7
7
|
var poolWorker = require('./pool-worker-81e8b4c0.js');
|
|
8
|
-
var machineWorker = require('./machine-worker-
|
|
8
|
+
var machineWorker = require('./machine-worker-16dad57f.js');
|
|
9
9
|
require('@leofcoin/codec-format-interface');
|
|
10
10
|
require('./transaction-220a3a15.js');
|
|
11
11
|
require('@vandeurenglenn/easy-worker');
|
|
@@ -141,7 +141,7 @@ const _init = async ({ contracts, blocks, peerid })=> {
|
|
|
141
141
|
return contract
|
|
142
142
|
}));
|
|
143
143
|
|
|
144
|
-
const _worker = new EasyWorker(join(__dirname, './block-worker.js'), {serialization: 'advanced'});
|
|
144
|
+
const _worker = await new EasyWorker(join(__dirname, './block-worker.js'), {serialization: 'advanced', type: 'module' });
|
|
145
145
|
// worker.on('message')
|
|
146
146
|
_worker.once('message', async (blocks) => {
|
|
147
147
|
for (const block of blocks) {
|
|
@@ -168,7 +168,7 @@ const _init = async ({ contracts, blocks, peerid })=> {
|
|
|
168
168
|
|
|
169
169
|
|
|
170
170
|
});
|
|
171
|
-
worker.
|
|
171
|
+
worker.postMessage(blocks);
|
|
172
172
|
};
|
|
173
173
|
|
|
174
174
|
const tasks = async (e) => {
|
package/dist/module/workers.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as transactionWorker } from './transaction-worker-105deaa8.js';
|
|
2
2
|
import { b as blockWorker } from './block-worker-f539b1b2.js';
|
|
3
3
|
import { p as poolWorker } from './pool-worker-f65671d7.js';
|
|
4
|
-
import { m as machineWorker } from './machine-worker-
|
|
4
|
+
import { m as machineWorker } from './machine-worker-a2897101.js';
|
|
5
5
|
import '@leofcoin/codec-format-interface';
|
|
6
6
|
import './transaction-d06dc6c4.js';
|
|
7
7
|
import '@vandeurenglenn/easy-worker';
|
package/package.json
CHANGED
package/src/machine-worker.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BlockMessage, ContractMessage
|
|
1
|
+
import { BlockMessage, ContractMessage } 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 { join } from 'path'
|
|
@@ -109,34 +109,32 @@ const _init = async ({ contracts, blocks, peerid })=> {
|
|
|
109
109
|
return contract
|
|
110
110
|
}))
|
|
111
111
|
|
|
112
|
-
const _worker = new EasyWorker(join(__dirname, './block-worker.js'), {serialization: 'advanced'})
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
let lastBlock
|
|
124
|
-
if (blocks.length > 0) {
|
|
125
|
-
lastBlock = blocks[blocks.length - 1].decoded
|
|
126
|
-
|
|
127
|
-
lastBlock = await new BlockMessage(lastBlock)
|
|
128
|
-
lastBlock = {
|
|
129
|
-
...lastBlock.decoded,
|
|
130
|
-
hash: await lastBlock.hash
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
worker.postMessage({type: 'machine-ready', lastBlock })
|
|
134
|
-
_worker.terminate()
|
|
135
|
-
|
|
112
|
+
const _worker = await new EasyWorker(join(__dirname, './block-worker.js'), {serialization: 'advanced', type: 'module' })
|
|
113
|
+
blocks = await _worker.once(blocks)
|
|
114
|
+
|
|
115
|
+
for (const block of blocks) {
|
|
116
|
+
await Promise.all(block.decoded.transactions.map(async message => {
|
|
117
|
+
const {from, to, method, params} = message;
|
|
118
|
+
globalThis.msg = createMessage(from);
|
|
119
|
+
|
|
120
|
+
await execute(to, method, params);
|
|
121
|
+
}));
|
|
122
|
+
}
|
|
136
123
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
124
|
+
let lastBlock;
|
|
125
|
+
if (blocks.length > 0) {
|
|
126
|
+
lastBlock = blocks[blocks.length - 1].decoded;
|
|
127
|
+
lastBlock = await new BlockMessage(lastBlock);
|
|
128
|
+
|
|
129
|
+
lastBlock = {
|
|
130
|
+
...lastBlock.decoded,
|
|
131
|
+
hash: await lastBlock.hash
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
worker.postMessage({type: 'machine-ready', lastBlock });
|
|
135
|
+
_worker.terminate();
|
|
136
|
+
|
|
137
|
+
worker.postMessage(blocks);
|
|
140
138
|
}
|
|
141
139
|
|
|
142
140
|
const tasks = async (e) => {
|