@leofcoin/workers 1.2.2 → 1.2.3

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.
@@ -143,33 +143,31 @@ const _init = async ({ contracts, blocks, peerid })=> {
143
143
  }));
144
144
 
145
145
  const _worker = await new worker$1.EasyWorker(require$$1.join(__dirname, './block-worker.js'), {serialization: 'advanced', type: 'module' });
146
- // worker.on('message')
147
- _worker.once('message', async (blocks) => {
148
- for (const block of blocks) {
149
- await Promise.all(block.decoded.transactions.map(async message => {
150
- const {from, to, method, params} = message;
151
- globalThis.msg = createMessage(from);
152
-
153
- await execute(to, method, params);
154
- }));
155
- }
156
- let lastBlock;
157
- if (blocks.length > 0) {
158
- lastBlock = blocks[blocks.length - 1].decoded;
159
-
160
- lastBlock = await new utils.BlockMessage(lastBlock);
161
- lastBlock = {
162
- ...lastBlock.decoded,
163
- hash: await lastBlock.hash
164
- };
165
- }
166
- worker.postMessage({type: 'machine-ready', lastBlock });
167
- _worker.terminate();
168
-
146
+ blocks = await _worker.once(blocks);
147
+
148
+ for (const block of blocks) {
149
+ await Promise.all(block.decoded.transactions.map(async message => {
150
+ const {from, to, method, params} = message;
151
+ globalThis.msg = createMessage(from);
152
+
153
+ await execute(to, method, params);
154
+ }));
155
+ }
169
156
 
170
-
171
- });
172
- worker.postMessage(blocks);
157
+ let lastBlock;
158
+ if (blocks.length > 0) {
159
+ lastBlock = blocks[blocks.length - 1].decoded;
160
+ lastBlock = await new utils.BlockMessage(lastBlock);
161
+
162
+ lastBlock = {
163
+ ...lastBlock.decoded,
164
+ hash: await lastBlock.hash
165
+ };
166
+ }
167
+ worker.postMessage({type: 'machine-ready', lastBlock });
168
+ _worker.terminate();
169
+
170
+ worker.postMessage(blocks);
173
171
  };
174
172
 
175
173
  const tasks = async (e) => {
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- require('./machine-worker-e96e3082.js');
3
+ require('./machine-worker-921195af.js');
4
4
  require('./worker-6ace445f.js');
5
5
  require('./utils-6e881be4.js');
6
6
  require('path');
@@ -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-e96e3082.js');
8
+ var machineWorker = require('./machine-worker-921195af.js');
9
9
  require('./worker-6ace445f.js');
10
10
  require('stream');
11
11
  require('events');
@@ -141,33 +141,31 @@ const _init = async ({ contracts, blocks, peerid })=> {
141
141
  }));
142
142
 
143
143
  const _worker = await new EasyWorker(join(__dirname, './block-worker.js'), {serialization: 'advanced', type: 'module' });
144
- // worker.on('message')
145
- _worker.once('message', async (blocks) => {
146
- for (const block of blocks) {
147
- await Promise.all(block.decoded.transactions.map(async message => {
148
- const {from, to, method, params} = message;
149
- globalThis.msg = createMessage(from);
150
-
151
- await execute(to, method, params);
152
- }));
153
- }
154
- let lastBlock;
155
- if (blocks.length > 0) {
156
- lastBlock = blocks[blocks.length - 1].decoded;
157
-
158
- lastBlock = await new BlockMessage(lastBlock);
159
- lastBlock = {
160
- ...lastBlock.decoded,
161
- hash: await lastBlock.hash
162
- };
163
- }
164
- worker.postMessage({type: 'machine-ready', lastBlock });
165
- _worker.terminate();
166
-
144
+ blocks = await _worker.once(blocks);
145
+
146
+ for (const block of blocks) {
147
+ await Promise.all(block.decoded.transactions.map(async message => {
148
+ const {from, to, method, params} = message;
149
+ globalThis.msg = createMessage(from);
150
+
151
+ await execute(to, method, params);
152
+ }));
153
+ }
167
154
 
168
-
169
- });
170
- worker.postMessage(blocks);
155
+ let lastBlock;
156
+ if (blocks.length > 0) {
157
+ lastBlock = blocks[blocks.length - 1].decoded;
158
+ lastBlock = await new BlockMessage(lastBlock);
159
+
160
+ lastBlock = {
161
+ ...lastBlock.decoded,
162
+ hash: await lastBlock.hash
163
+ };
164
+ }
165
+ worker.postMessage({type: 'machine-ready', lastBlock });
166
+ _worker.terminate();
167
+
168
+ worker.postMessage(blocks);
171
169
  };
172
170
 
173
171
  const tasks = async (e) => {
@@ -1,4 +1,4 @@
1
- import './machine-worker-e3020b69.js';
1
+ import './machine-worker-73a4ed96.js';
2
2
  import './worker-def77c26.js';
3
3
  import './utils-ac8c68e6.js';
4
4
  import 'path';
@@ -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-e3020b69.js';
4
+ import { m as machineWorker } from './machine-worker-73a4ed96.js';
5
5
  import './worker-def77c26.js';
6
6
  import 'stream';
7
7
  import 'events';
@@ -148,33 +148,31 @@ const _init = async ({ contracts, blocks, peerid })=> {
148
148
  }));
149
149
 
150
150
  const _worker = await new EasyWorker__default["default"](path.join(__dirname, './block-worker.js'), {serialization: 'advanced', type: 'module' });
151
- // worker.on('message')
152
- _worker.once('message', async (blocks) => {
153
- for (const block of blocks) {
154
- await Promise.all(block.decoded.transactions.map(async message => {
155
- const {from, to, method, params} = message;
156
- globalThis.msg = createMessage(from);
157
-
158
- await execute(to, method, params);
159
- }));
160
- }
161
- let lastBlock;
162
- if (blocks.length > 0) {
163
- lastBlock = blocks[blocks.length - 1].decoded;
164
-
165
- lastBlock = await new utils.BlockMessage(lastBlock);
166
- lastBlock = {
167
- ...lastBlock.decoded,
168
- hash: await lastBlock.hash
169
- };
170
- }
171
- worker.postMessage({type: 'machine-ready', lastBlock });
172
- _worker.terminate();
173
-
151
+ blocks = await _worker.once(blocks);
152
+
153
+ for (const block of blocks) {
154
+ await Promise.all(block.decoded.transactions.map(async message => {
155
+ const {from, to, method, params} = message;
156
+ globalThis.msg = createMessage(from);
157
+
158
+ await execute(to, method, params);
159
+ }));
160
+ }
174
161
 
175
-
176
- });
177
- worker.postMessage(blocks);
162
+ let lastBlock;
163
+ if (blocks.length > 0) {
164
+ lastBlock = blocks[blocks.length - 1].decoded;
165
+ lastBlock = await new utils.BlockMessage(lastBlock);
166
+
167
+ lastBlock = {
168
+ ...lastBlock.decoded,
169
+ hash: await lastBlock.hash
170
+ };
171
+ }
172
+ worker.postMessage({type: 'machine-ready', lastBlock });
173
+ _worker.terminate();
174
+
175
+ worker.postMessage(blocks);
178
176
  };
179
177
 
180
178
  const tasks = async (e) => {
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- require('./machine-worker-16dad57f.js');
3
+ require('./machine-worker-883fbad2.js');
4
4
  require('@leofcoin/codec-format-interface');
5
5
  require('./utils-1dc37f72.js');
6
6
  require('path');
@@ -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-16dad57f.js');
8
+ var machineWorker = require('./machine-worker-883fbad2.js');
9
9
  require('@leofcoin/codec-format-interface');
10
10
  require('./transaction-220a3a15.js');
11
11
  require('@vandeurenglenn/easy-worker');
@@ -142,33 +142,31 @@ const _init = async ({ contracts, blocks, peerid })=> {
142
142
  }));
143
143
 
144
144
  const _worker = await new EasyWorker(join(__dirname, './block-worker.js'), {serialization: 'advanced', type: 'module' });
145
- // worker.on('message')
146
- _worker.once('message', async (blocks) => {
147
- for (const block of blocks) {
148
- await Promise.all(block.decoded.transactions.map(async message => {
149
- const {from, to, method, params} = message;
150
- globalThis.msg = createMessage(from);
151
-
152
- await execute(to, method, params);
153
- }));
154
- }
155
- let lastBlock;
156
- if (blocks.length > 0) {
157
- lastBlock = blocks[blocks.length - 1].decoded;
158
-
159
- lastBlock = await new BlockMessage(lastBlock);
160
- lastBlock = {
161
- ...lastBlock.decoded,
162
- hash: await lastBlock.hash
163
- };
164
- }
165
- worker.postMessage({type: 'machine-ready', lastBlock });
166
- _worker.terminate();
167
-
145
+ blocks = await _worker.once(blocks);
146
+
147
+ for (const block of blocks) {
148
+ await Promise.all(block.decoded.transactions.map(async message => {
149
+ const {from, to, method, params} = message;
150
+ globalThis.msg = createMessage(from);
151
+
152
+ await execute(to, method, params);
153
+ }));
154
+ }
168
155
 
169
-
170
- });
171
- worker.postMessage(blocks);
156
+ let lastBlock;
157
+ if (blocks.length > 0) {
158
+ lastBlock = blocks[blocks.length - 1].decoded;
159
+ lastBlock = await new BlockMessage(lastBlock);
160
+
161
+ lastBlock = {
162
+ ...lastBlock.decoded,
163
+ hash: await lastBlock.hash
164
+ };
165
+ }
166
+ worker.postMessage({type: 'machine-ready', lastBlock });
167
+ _worker.terminate();
168
+
169
+ worker.postMessage(blocks);
172
170
  };
173
171
 
174
172
  const tasks = async (e) => {
@@ -1,4 +1,4 @@
1
- import './machine-worker-a2897101.js';
1
+ import './machine-worker-a213bc02.js';
2
2
  import '@leofcoin/codec-format-interface';
3
3
  import './utils-e87bc63d.js';
4
4
  import 'path';
@@ -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-a2897101.js';
4
+ import { m as machineWorker } from './machine-worker-a213bc02.js';
5
5
  import '@leofcoin/codec-format-interface';
6
6
  import './transaction-d06dc6c4.js';
7
7
  import '@vandeurenglenn/easy-worker';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leofcoin/workers",
3
- "version": "1.2.2",
3
+ "version": "1.2.3",
4
4
  "description": "",
5
5
  "module": "src/workers.js",
6
6
  "scripts": {