@leofcoin/workers 1.4.17 → 1.4.19
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/CHANGELOG.md +17 -0
- package/package.json +6 -6
- package/src/machine-worker.js +32 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @leofcoin/workers
|
|
2
2
|
|
|
3
|
+
## 1.4.19
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 78299bf: bump
|
|
8
|
+
- Updated dependencies [78299bf]
|
|
9
|
+
- @leofcoin/addresses@1.0.23
|
|
10
|
+
- @leofcoin/lib@1.2.43
|
|
11
|
+
- @leofcoin/messages@1.4.13
|
|
12
|
+
- @leofcoin/utils@1.1.18
|
|
13
|
+
|
|
14
|
+
## 1.4.18
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- Fix browser build
|
|
19
|
+
|
|
3
20
|
## 1.4.17
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leofcoin/workers",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.19",
|
|
4
4
|
"description": "Workers used in @leofcoin/chain",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
@@ -21,11 +21,11 @@
|
|
|
21
21
|
"author": "",
|
|
22
22
|
"license": "MIT",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@leofcoin/addresses": "^1.0.
|
|
25
|
-
"@leofcoin/lib": "^1.2.
|
|
26
|
-
"@leofcoin/messages": "^1.4.
|
|
27
|
-
"@leofcoin/storage": "^3.5.
|
|
28
|
-
"@leofcoin/utils": "^1.1.
|
|
24
|
+
"@leofcoin/addresses": "^1.0.23",
|
|
25
|
+
"@leofcoin/lib": "^1.2.43",
|
|
26
|
+
"@leofcoin/messages": "^1.4.13",
|
|
27
|
+
"@leofcoin/storage": "^3.5.28",
|
|
28
|
+
"@leofcoin/utils": "^1.1.18",
|
|
29
29
|
"@vandeurenglenn/easy-worker": "^1.0.2"
|
|
30
30
|
}
|
|
31
31
|
}
|
package/src/machine-worker.js
CHANGED
|
@@ -4,7 +4,6 @@ import addresses from '@leofcoin/addresses'
|
|
|
4
4
|
import bytecodes from '@leofcoin/lib/bytecodes' assert { type: 'json' }
|
|
5
5
|
import EasyWorker from '@vandeurenglenn/easy-worker'
|
|
6
6
|
import { nativeToken } from '@leofcoin/addresses'
|
|
7
|
-
import { randomUUID } from 'crypto'
|
|
8
7
|
import LittlePubSub from '@vandeurenglenn/little-pubsub'
|
|
9
8
|
const pubsub = new LittlePubSub()
|
|
10
9
|
const worker = new EasyWorker()
|
|
@@ -136,9 +135,18 @@ const _executeTransaction = async (transaction) => {
|
|
|
136
135
|
await _.execute({ contract: to, method, params })
|
|
137
136
|
if (to === nativeToken) {
|
|
138
137
|
nativeCalls += 1
|
|
139
|
-
if (method === 'burn')
|
|
140
|
-
|
|
141
|
-
|
|
138
|
+
if (method === 'burn') {
|
|
139
|
+
nativeBurns += 1
|
|
140
|
+
totalBurnAmount += params[0]
|
|
141
|
+
}
|
|
142
|
+
if (method === 'mint') {
|
|
143
|
+
nativeMints += 1
|
|
144
|
+
totalMintAmount += params[0]
|
|
145
|
+
}
|
|
146
|
+
if (method === 'transfer') {
|
|
147
|
+
nativeTransfers += 1
|
|
148
|
+
totalTransferAmount += params[0]
|
|
149
|
+
}
|
|
142
150
|
}
|
|
143
151
|
totalTransactions += 1
|
|
144
152
|
|
|
@@ -154,10 +162,19 @@ const _executeTransaction = async (transaction) => {
|
|
|
154
162
|
}
|
|
155
163
|
|
|
156
164
|
_.init = async (message) => {
|
|
157
|
-
let { peerid, fromState, state } = message
|
|
165
|
+
let { peerid, fromState, state, info } = message
|
|
158
166
|
globalThis.peerid = peerid
|
|
159
167
|
console.log({ fromState })
|
|
160
168
|
if (fromState) {
|
|
169
|
+
nativeCalls = info.nativeCalls
|
|
170
|
+
nativeBurns = info.nativeBurns
|
|
171
|
+
nativeMints = info.nativeMints
|
|
172
|
+
nativeTransfers = info.nativeTransfers
|
|
173
|
+
totalTransactions = info.totalTransactions
|
|
174
|
+
totalBurnAmount = info.totalBurnAmount
|
|
175
|
+
totalMintAmount = info.totalMintAmount
|
|
176
|
+
totalTransferAmount = info.totalTransferAmount
|
|
177
|
+
|
|
161
178
|
lastBlock = message.lastBlock
|
|
162
179
|
const setState = async (address, state) => {
|
|
163
180
|
const contractBytes = await resolveContract(address)
|
|
@@ -275,7 +292,7 @@ _.loadBlock = (block) => {
|
|
|
275
292
|
|
|
276
293
|
const askFor = (question, input) =>
|
|
277
294
|
new Promise((resolve) => {
|
|
278
|
-
const id = randomUUID()
|
|
295
|
+
const id = globalThis.crypto.randomUUID()
|
|
279
296
|
pubsub.subscribe(id, resolve)
|
|
280
297
|
worker.postMessage({
|
|
281
298
|
type: 'ask',
|
|
@@ -331,6 +348,15 @@ worker.onmessage(({ id, type, input }) => {
|
|
|
331
348
|
case 'nativeTransfers':
|
|
332
349
|
respond(id, nativeTransfers)
|
|
333
350
|
break
|
|
351
|
+
case 'totalBurnAmount':
|
|
352
|
+
respond(id, totalBurnAmount)
|
|
353
|
+
break
|
|
354
|
+
case 'totalMintAmount':
|
|
355
|
+
respond(id, totalMintAmount)
|
|
356
|
+
break
|
|
357
|
+
case 'totalTransferAmount':
|
|
358
|
+
respond(id, totalTransferAmount)
|
|
359
|
+
break
|
|
334
360
|
case 'totalTransfers':
|
|
335
361
|
respond(id, totalTransfers)
|
|
336
362
|
break
|