@leofcoin/workers 1.3.13 → 1.3.15
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/machine-worker.js +13 -4
package/package.json
CHANGED
package/src/machine-worker.js
CHANGED
|
@@ -68,9 +68,7 @@ const execute = async (contract, method, params) => {
|
|
|
68
68
|
return result
|
|
69
69
|
} catch (e) {
|
|
70
70
|
throw new Error(
|
|
71
|
-
`
|
|
72
|
-
error: ${e}
|
|
73
|
-
|
|
71
|
+
`error: ${e.message}
|
|
74
72
|
contract: ${contract}
|
|
75
73
|
method: ${method}
|
|
76
74
|
params: ${JSON.stringify(params, null, '\t')}
|
|
@@ -107,7 +105,18 @@ const _init = async ({ contracts, blocks, peerid })=> {
|
|
|
107
105
|
let lastBlock = {hash: '0x0'};
|
|
108
106
|
|
|
109
107
|
if (blocks?.length > 0) {
|
|
110
|
-
|
|
108
|
+
let pre
|
|
109
|
+
|
|
110
|
+
try {
|
|
111
|
+
const importee = await import('url')
|
|
112
|
+
const url = importee.default
|
|
113
|
+
if (url) pre = url.fileURLToPath(new URL('.', import.meta.url));
|
|
114
|
+
} catch {
|
|
115
|
+
// browser env
|
|
116
|
+
pre = './'
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const _worker = await new EasyWorker(pre + '@leofcoin/workers/block-worker.js', {serialization: 'advanced', type: 'module' })
|
|
111
120
|
blocks = await _worker.once([blocks[blocks.length - 1]])
|
|
112
121
|
|
|
113
122
|
// blocks = unique(globalThis.blocks ? globalThis : [], blocks)
|