@leofcoin/chain 1.5.54 → 1.5.56
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/exports/browser/chain.js +4 -2
- package/exports/browser/workers/block-worker.js +1 -0
- package/exports/browser/workers/machine-worker.js +3 -3
- package/exports/chain.js +4 -2
- package/exports/workers/block-worker.js +1 -0
- package/exports/workers/machine-worker.js +3 -3
- package/package.json +1 -1
package/exports/browser/chain.js
CHANGED
|
@@ -3882,11 +3882,13 @@ class Machine {
|
|
|
3882
3882
|
const { from, nonce, hash } = data.result;
|
|
3883
3883
|
(await transactionPoolStore.has(hash)) && (await transactionPoolStore.delete(hash));
|
|
3884
3884
|
await accountsStore.put(from, nonce);
|
|
3885
|
+
break;
|
|
3885
3886
|
}
|
|
3886
3887
|
case 'contractError': {
|
|
3887
|
-
console.warn(
|
|
3888
|
+
console.warn(data.error);
|
|
3889
|
+
console.warn(`contract error: ${data.hash}`);
|
|
3888
3890
|
// @ts-ignore
|
|
3889
|
-
await contractStore.delete(
|
|
3891
|
+
await contractStore.delete(data.hash);
|
|
3890
3892
|
break;
|
|
3891
3893
|
}
|
|
3892
3894
|
case 'initError': {
|
|
@@ -20,6 +20,7 @@ const run = async (blocks) => {
|
|
|
20
20
|
const index = block.decoded.index;
|
|
21
21
|
console.log(`loaded block: ${hash} @${index} ${formatBytes(size)}`);
|
|
22
22
|
// todo we don't want this, need shared state
|
|
23
|
+
block.decoded.transactions = block.decoded.transactions.sort((a, b) => a.nonce - b.nonce);
|
|
23
24
|
resolve({ ...block.decoded, blockInfo: { hash, size, index } });
|
|
24
25
|
})
|
|
25
26
|
)
|
|
@@ -62,13 +62,14 @@ const runContract = async ({ decoded, hash, encoded }) => {
|
|
|
62
62
|
contracts[hash] = await new Contract(...params);
|
|
63
63
|
worker.postMessage({
|
|
64
64
|
type: 'debug',
|
|
65
|
-
|
|
65
|
+
message: `loaded contract: ${hash} size: ${formatBytes(encoded.length)}`
|
|
66
66
|
});
|
|
67
67
|
} catch (e) {
|
|
68
68
|
console.log(e);
|
|
69
69
|
worker.postMessage({
|
|
70
70
|
type: 'contractError',
|
|
71
|
-
|
|
71
|
+
message: e.message,
|
|
72
|
+
hash
|
|
72
73
|
});
|
|
73
74
|
}
|
|
74
75
|
};
|
|
@@ -134,7 +135,6 @@ const _init = async ({ contracts, blocks, peerid }) => {
|
|
|
134
135
|
type: 'module'
|
|
135
136
|
});
|
|
136
137
|
blocks = await _worker.once(blocks);
|
|
137
|
-
console.log({ blocks });
|
|
138
138
|
_worker = null;
|
|
139
139
|
// blocks = unique(globalThis.blocks ? globalThis : [], blocks)
|
|
140
140
|
// for (let i = 0; i < blocks.length; i++) {
|
package/exports/chain.js
CHANGED
|
@@ -293,11 +293,13 @@ class Machine {
|
|
|
293
293
|
const { from, nonce, hash } = data.result;
|
|
294
294
|
(await transactionPoolStore.has(hash)) && (await transactionPoolStore.delete(hash));
|
|
295
295
|
await accountsStore.put(from, nonce);
|
|
296
|
+
break;
|
|
296
297
|
}
|
|
297
298
|
case 'contractError': {
|
|
298
|
-
console.warn(
|
|
299
|
+
console.warn(data.error);
|
|
300
|
+
console.warn(`contract error: ${data.hash}`);
|
|
299
301
|
// @ts-ignore
|
|
300
|
-
await contractStore.delete(
|
|
302
|
+
await contractStore.delete(data.hash);
|
|
301
303
|
break;
|
|
302
304
|
}
|
|
303
305
|
case 'initError': {
|
|
@@ -20,6 +20,7 @@ const run = async (blocks) => {
|
|
|
20
20
|
const index = block.decoded.index;
|
|
21
21
|
console.log(`loaded block: ${hash} @${index} ${formatBytes(size)}`);
|
|
22
22
|
// todo we don't want this, need shared state
|
|
23
|
+
block.decoded.transactions = block.decoded.transactions.sort((a, b) => a.nonce - b.nonce);
|
|
23
24
|
resolve({ ...block.decoded, blockInfo: { hash, size, index } });
|
|
24
25
|
})
|
|
25
26
|
)
|
|
@@ -62,13 +62,14 @@ const runContract = async ({ decoded, hash, encoded }) => {
|
|
|
62
62
|
contracts[hash] = await new Contract(...params);
|
|
63
63
|
worker.postMessage({
|
|
64
64
|
type: 'debug',
|
|
65
|
-
|
|
65
|
+
message: `loaded contract: ${hash} size: ${formatBytes(encoded.length)}`
|
|
66
66
|
});
|
|
67
67
|
} catch (e) {
|
|
68
68
|
console.log(e);
|
|
69
69
|
worker.postMessage({
|
|
70
70
|
type: 'contractError',
|
|
71
|
-
|
|
71
|
+
message: e.message,
|
|
72
|
+
hash
|
|
72
73
|
});
|
|
73
74
|
}
|
|
74
75
|
};
|
|
@@ -134,7 +135,6 @@ const _init = async ({ contracts, blocks, peerid }) => {
|
|
|
134
135
|
type: 'module'
|
|
135
136
|
});
|
|
136
137
|
blocks = await _worker.once(blocks);
|
|
137
|
-
console.log({ blocks });
|
|
138
138
|
_worker = null;
|
|
139
139
|
// blocks = unique(globalThis.blocks ? globalThis : [], blocks)
|
|
140
140
|
// for (let i = 0; i < blocks.length; i++) {
|