@leofcoin/workers 1.3.9 → 1.3.10

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leofcoin/workers",
3
- "version": "1.3.9",
3
+ "version": "1.3.10",
4
4
  "description": "Workers used in @leofcoin/chain",
5
5
  "type": "module",
6
6
  "exports": {
@@ -6,8 +6,6 @@ import EasyWorker from '@vandeurenglenn/easy-worker'
6
6
  const worker = new EasyWorker()
7
7
 
8
8
  globalThis.BigNumber = BigNumber
9
-
10
- globalThis.peernet = globalThis.peernet || {}
11
9
  globalThis.contracts = {}
12
10
 
13
11
  const run = async (blocks) => {
@@ -23,14 +21,7 @@ const run = async (blocks) => {
23
21
  return blocks
24
22
  }
25
23
 
26
- const tasks = async blocks => {
27
- globalThis.peernet.codecs = {
28
- 'block-message': {
29
- codec: parseInt('626d', 16),
30
- hashAlg: 'keccak-256'
31
- }
32
- }
33
-
24
+ const tasks = async blocks => {
34
25
  blocks = await run(blocks)
35
26
  worker.postMessage(blocks)
36
27
  }
@@ -10,8 +10,6 @@ const nameServiceMessage = bytecodes.nameService
10
10
  const validatorsMessage = bytecodes.validators
11
11
 
12
12
  globalThis.BigNumber = BigNumber
13
-
14
- globalThis.peernet = globalThis.peernet || {}
15
13
  globalThis.contracts = {}
16
14
 
17
15
  const unique = arr => arr.filter((el, pos, arr) => {
@@ -36,7 +34,7 @@ const runContract = async ({decoded, hash, encoded}) => {
36
34
  const params = decoded.constructorParameters
37
35
  try {
38
36
 
39
- const func = new Function(decoded.contract)
37
+ const func = new Function(new TextDecoder().decode(contract))
40
38
  const Contract = func()
41
39
 
42
40
  globalThis.msg = createMessage(decoded.creator)
@@ -83,21 +81,6 @@ const createMessage = (sender = globalThis.peerid) => {
83
81
  }
84
82
 
85
83
  const _init = async ({ contracts, blocks, peerid })=> {
86
-
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
84
 
102
85
  globalThis.peerid = peerid
103
86
  contracts = [
@@ -1,21 +1,12 @@
1
1
  import { TransactionMessage } from '@leofcoin/messages'
2
2
 
3
3
  import EasyWorker from '@vandeurenglenn/easy-worker'
4
-
5
- globalThis.peernet = globalThis.peernet || {}
6
4
  globalThis.contracts = {}
7
5
 
8
6
  const worker = new EasyWorker()
9
7
 
10
8
  const tasks = async transactions => {
11
9
 
12
- globalThis.peernet.codecs = {
13
- 'transaction-message': {
14
- codec: parseInt('746d', 16),
15
- hashAlg: 'keccak-256'
16
- }
17
- }
18
-
19
10
  transactions = await Promise.all(transactions.map(async message => {
20
11
  message = await new TransactionMessage(message)
21
12
 
@@ -1,19 +1,11 @@
1
1
  import { TransactionMessage } from '@leofcoin/messages'
2
-
3
- globalThis.peernet = globalThis.peernet || {}
4
2
  globalThis.contracts = {}
5
3
 
6
4
  import EasyWorker from '@vandeurenglenn/easy-worker'
7
5
 
8
6
  const worker = new EasyWorker()
9
7
 
10
- worker.onmessage(async (transactions) => {
11
- globalThis.peernet.codecs = {
12
- 'transaction-message': {
13
- codec: parseInt('746d', 16),
14
- hashAlg: 'keccak-256'
15
- }
16
- }
8
+ worker.onmessage(async (transactions) => {
17
9
  transactions = await Promise.all(transactions.map(async message => new TransactionMessage(message)))
18
10
 
19
11
  worker.postMessage(transactions)