@leofcoin/workers 1.3.5 → 1.3.7
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/package.json +10 -9
- package/src/block-worker.js +3 -3
- package/src/machine-worker.js +7 -8
- package/src/pool-worker.js +2 -2
- package/src/transaction-worker.js +1 -1
- package/src/workers.js +4 -4
- package/rollup.config.js +0 -40
package/package.json
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leofcoin/workers",
|
|
3
|
-
"version": "1.3.
|
|
4
|
-
"description": "",
|
|
5
|
-
"
|
|
3
|
+
"version": "1.3.7",
|
|
4
|
+
"description": "Workers used in @leofcoin/chain",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": "./src/workers.js",
|
|
8
|
+
"./machine-worker": "./src/machine-worker.js",
|
|
9
|
+
"./block-worker": "./src/block-worker.js",
|
|
10
|
+
"./transaction-worker": "./src/transaction-worker.js",
|
|
11
|
+
"./pool-worker": "./src/pool-worker.js"
|
|
12
|
+
},
|
|
6
13
|
"scripts": {
|
|
7
14
|
"build": "rollup -c",
|
|
8
15
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
@@ -10,12 +17,6 @@
|
|
|
10
17
|
"keywords": [],
|
|
11
18
|
"author": "",
|
|
12
19
|
"license": "MIT",
|
|
13
|
-
"devDependencies": {
|
|
14
|
-
"@rollup/plugin-commonjs": "^22.0.2",
|
|
15
|
-
"@rollup/plugin-json": "^4.1.0",
|
|
16
|
-
"@rollup/plugin-node-resolve": "^14.1.0",
|
|
17
|
-
"rollup": "^2.79.1"
|
|
18
|
-
},
|
|
19
20
|
"dependencies": {
|
|
20
21
|
"@leofcoin/messages": "^1.2.0"
|
|
21
22
|
}
|
package/src/block-worker.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { BlockMessage } from '
|
|
2
|
-
import { formatBytes, BigNumber } from '
|
|
1
|
+
import { BlockMessage } from '@leofcoin/messages'
|
|
2
|
+
import { formatBytes, BigNumber } from '@leofcoin/utils'
|
|
3
3
|
|
|
4
4
|
import EasyWorker from '@vandeurenglenn/easy-worker'
|
|
5
5
|
|
|
@@ -17,7 +17,7 @@ const run = async (blocks) => {
|
|
|
17
17
|
blocks = await Promise.all(blocks.map(block => new Promise(async (resolve, reject) => {
|
|
18
18
|
// todo: tx worker or nah?
|
|
19
19
|
const size = block.encoded.length || block.encoded.byteLength
|
|
20
|
-
console.log(`loaded block: ${await block.hash} @${block.decoded.index} ${formatBytes(size)}`);
|
|
20
|
+
console.log(`loaded block: ${await block.hash()} @${block.decoded.index} ${formatBytes(size)}`);
|
|
21
21
|
resolve(block)
|
|
22
22
|
})))
|
|
23
23
|
return blocks
|
package/src/machine-worker.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { BlockMessage, ContractMessage } from '
|
|
2
|
-
import { formatBytes, BigNumber } from '
|
|
3
|
-
import bytecodes from '
|
|
4
|
-
|
|
1
|
+
import { BlockMessage, ContractMessage } from '@leofcoin/messages'
|
|
2
|
+
import { formatBytes, BigNumber } from '@leofcoin/utils'
|
|
3
|
+
import bytecodes from '@leofcoin/lib/bytecodes' assert {type: 'json'}
|
|
5
4
|
import EasyWorker from '@vandeurenglenn/easy-worker'
|
|
6
5
|
const worker = new EasyWorker()
|
|
7
6
|
|
|
@@ -49,7 +48,7 @@ const runContract = async ({decoded, hash, encoded}) => {
|
|
|
49
48
|
console.log(e);
|
|
50
49
|
worker.postMessage({
|
|
51
50
|
type: 'contractError',
|
|
52
|
-
hash: await contractMessage.hash
|
|
51
|
+
hash: await contractMessage.hash()
|
|
53
52
|
})
|
|
54
53
|
}
|
|
55
54
|
}
|
|
@@ -106,7 +105,7 @@ const _init = async ({ contracts, blocks, peerid })=> {
|
|
|
106
105
|
|
|
107
106
|
contracts = await Promise.all(contracts.map(async contract => {
|
|
108
107
|
contract = await new ContractMessage(new Uint8Array(contract.split(',')))
|
|
109
|
-
await runContract({decoded: contract.decoded, encoded: contract.encoded, hash: await contract.hash})
|
|
108
|
+
await runContract({decoded: contract.decoded, encoded: contract.encoded, hash: await contract.hash()})
|
|
110
109
|
return contract
|
|
111
110
|
}))
|
|
112
111
|
|
|
@@ -138,7 +137,7 @@ const _init = async ({ contracts, blocks, peerid })=> {
|
|
|
138
137
|
|
|
139
138
|
lastBlock = {
|
|
140
139
|
...lastBlock.decoded,
|
|
141
|
-
hash: await lastBlock.hash
|
|
140
|
+
hash: await lastBlock.hash()
|
|
142
141
|
};
|
|
143
142
|
}
|
|
144
143
|
globalThis.blocks = blocks
|
|
@@ -175,7 +174,7 @@ const tasks = async (e) => {
|
|
|
175
174
|
})
|
|
176
175
|
} catch (e) {
|
|
177
176
|
worker.postMessage({
|
|
178
|
-
type: '
|
|
177
|
+
type: 'runError',
|
|
179
178
|
message: e.message,
|
|
180
179
|
id
|
|
181
180
|
})
|
package/src/pool-worker.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TransactionMessage } from '
|
|
1
|
+
import { TransactionMessage } from '@leofcoin/messages'
|
|
2
2
|
|
|
3
3
|
import EasyWorker from '@vandeurenglenn/easy-worker'
|
|
4
4
|
|
|
@@ -19,7 +19,7 @@ const tasks = async transactions => {
|
|
|
19
19
|
transactions = await Promise.all(transactions.map(async message => {
|
|
20
20
|
message = await new TransactionMessage(message)
|
|
21
21
|
|
|
22
|
-
return {...message.decoded, hash: await message.hash, size: message.encoded.length}
|
|
22
|
+
return {...message.decoded, hash: await message.hash(), size: message.encoded.length}
|
|
23
23
|
}))
|
|
24
24
|
|
|
25
25
|
worker.postMessage(transactions)
|
package/src/workers.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as transactionWorker from './transaction-worker'
|
|
2
|
-
import * as blockWorker from './block-worker'
|
|
3
|
-
import * as poolWorker from './pool-worker'
|
|
4
|
-
import * as machineWorker from './machine-worker'
|
|
1
|
+
import * as transactionWorker from './transaction-worker.js'
|
|
2
|
+
import * as blockWorker from './block-worker.js'
|
|
3
|
+
import * as poolWorker from './pool-worker.js'
|
|
4
|
+
import * as machineWorker from './machine-worker.js'
|
|
5
5
|
|
|
6
6
|
export const TransactionWorker = transactionWorker
|
|
7
7
|
export const BlockWorker = blockWorker
|
package/rollup.config.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { execSync } from 'child_process'
|
|
2
|
-
import json from '@rollup/plugin-json'
|
|
3
|
-
import resolve from '@rollup/plugin-node-resolve'
|
|
4
|
-
|
|
5
|
-
import commonjs from '@rollup/plugin-commonjs'
|
|
6
|
-
try {
|
|
7
|
-
execSync(`rm -rf ./dist/**`)
|
|
8
|
-
|
|
9
|
-
} catch (e) {
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
export default [{
|
|
13
|
-
input: ['./src/workers.js', './src/transaction-worker.js', './src/block-worker.js', './src/pool-worker.js', './src/machine-worker.js'],
|
|
14
|
-
|
|
15
|
-
plugins: [
|
|
16
|
-
json()
|
|
17
|
-
],
|
|
18
|
-
output: [{
|
|
19
|
-
dir: './dist/commonjs',
|
|
20
|
-
format: 'cjs'
|
|
21
|
-
}, {
|
|
22
|
-
dir: './dist/module',
|
|
23
|
-
format: 'es'
|
|
24
|
-
}]
|
|
25
|
-
}, {
|
|
26
|
-
input: ['./src/workers.js', './src/transaction-worker.js', './src/block-worker.js', './src/pool-worker.js', './src/machine-worker.js'],
|
|
27
|
-
|
|
28
|
-
plugins: [
|
|
29
|
-
json(),
|
|
30
|
-
commonjs(),
|
|
31
|
-
resolve()
|
|
32
|
-
],
|
|
33
|
-
output: [{
|
|
34
|
-
dir: './dist/bundle/commonjs',
|
|
35
|
-
format: 'cjs'
|
|
36
|
-
}, {
|
|
37
|
-
dir: './dist/bundle/module',
|
|
38
|
-
format: 'es'
|
|
39
|
-
}]
|
|
40
|
-
}]
|