@leofcoin/workers 1.4.5 → 1.4.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 +1 -1
- package/src/block-worker.js +1 -0
- package/src/machine-worker.js +4 -4
package/package.json
CHANGED
package/src/block-worker.js
CHANGED
|
@@ -23,6 +23,7 @@ const run = async (blocks) => {
|
|
|
23
23
|
const index = block.decoded.index
|
|
24
24
|
console.log(`loaded block: ${hash} @${index} ${formatBytes(size)}`)
|
|
25
25
|
// todo we don't want this, need shared state
|
|
26
|
+
block.decoded.transactions = block.decoded.transactions.sort((a, b) => a.nonce - b.nonce)
|
|
26
27
|
resolve({ ...block.decoded, blockInfo: { hash, size, index } })
|
|
27
28
|
})
|
|
28
29
|
)
|
package/src/machine-worker.js
CHANGED
|
@@ -51,13 +51,14 @@ const runContract = async ({ decoded, hash, encoded }) => {
|
|
|
51
51
|
contracts[hash] = await new Contract(...params)
|
|
52
52
|
worker.postMessage({
|
|
53
53
|
type: 'debug',
|
|
54
|
-
|
|
54
|
+
message: `loaded contract: ${hash} size: ${formatBytes(encoded.length)}`
|
|
55
55
|
})
|
|
56
56
|
} catch (e) {
|
|
57
57
|
console.log(e)
|
|
58
58
|
worker.postMessage({
|
|
59
59
|
type: 'contractError',
|
|
60
|
-
|
|
60
|
+
message: e.message,
|
|
61
|
+
hash
|
|
61
62
|
})
|
|
62
63
|
}
|
|
63
64
|
}
|
|
@@ -123,7 +124,6 @@ const _init = async ({ contracts, blocks, peerid }) => {
|
|
|
123
124
|
type: 'module'
|
|
124
125
|
})
|
|
125
126
|
blocks = await _worker.once(blocks)
|
|
126
|
-
console.log({ blocks })
|
|
127
127
|
_worker = null
|
|
128
128
|
// blocks = unique(globalThis.blocks ? globalThis : [], blocks)
|
|
129
129
|
// for (let i = 0; i < blocks.length; i++) {
|
|
@@ -147,7 +147,7 @@ const _init = async ({ contracts, blocks, peerid }) => {
|
|
|
147
147
|
}
|
|
148
148
|
totalTransactions += 1
|
|
149
149
|
|
|
150
|
-
postMessage({
|
|
150
|
+
worker.postMessage({
|
|
151
151
|
type: 'transactionLoaded',
|
|
152
152
|
result: {
|
|
153
153
|
hash: await new TransactionMessage(transaction).hash(),
|