@leofcoin/chain 1.7.87 → 1.7.90
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 +8 -4
- package/exports/chain.js +8 -4
- package/exports/state.d.ts +1 -1
- package/package.json +4 -4
package/exports/browser/chain.js
CHANGED
|
@@ -4232,13 +4232,17 @@ class Machine {
|
|
|
4232
4232
|
}
|
|
4233
4233
|
async updateState() {
|
|
4234
4234
|
try {
|
|
4235
|
-
|
|
4236
|
-
|
|
4235
|
+
const lastBlock = await this.lastBlock;
|
|
4236
|
+
const lastBlockIndex = Number(lastBlock.index);
|
|
4237
|
+
const statesLastBlockIndex = Number(this.states.lastBlock.index);
|
|
4238
|
+
if (lastBlockIndex > statesLastBlockIndex ||
|
|
4239
|
+
(lastBlock.hash !== this.states.lastBlock.hash && Number(lastBlockIndex) === 0)) {
|
|
4237
4240
|
// todo only get state for changed contracts
|
|
4238
|
-
const blocks = (await this.blocks).slice(
|
|
4241
|
+
const blocks = (await this.blocks).slice(statesLastBlockIndex);
|
|
4239
4242
|
let transactions = [];
|
|
4240
4243
|
for (const block of blocks) {
|
|
4241
|
-
|
|
4244
|
+
if (block?.transactions)
|
|
4245
|
+
transactions = [...transactions, ...block.transactions];
|
|
4242
4246
|
}
|
|
4243
4247
|
transactions = await Promise.all(transactions.map(async (transaction) => new TransactionMessage(await transactionStore.get(transaction))));
|
|
4244
4248
|
const contractsToGet = transactions.reduce((set, current) => {
|
package/exports/chain.js
CHANGED
|
@@ -378,13 +378,17 @@ class Machine {
|
|
|
378
378
|
}
|
|
379
379
|
async updateState() {
|
|
380
380
|
try {
|
|
381
|
-
|
|
382
|
-
|
|
381
|
+
const lastBlock = await this.lastBlock;
|
|
382
|
+
const lastBlockIndex = Number(lastBlock.index);
|
|
383
|
+
const statesLastBlockIndex = Number(this.states.lastBlock.index);
|
|
384
|
+
if (lastBlockIndex > statesLastBlockIndex ||
|
|
385
|
+
(lastBlock.hash !== this.states.lastBlock.hash && Number(lastBlockIndex) === 0)) {
|
|
383
386
|
// todo only get state for changed contracts
|
|
384
|
-
const blocks = (await this.blocks).slice(
|
|
387
|
+
const blocks = (await this.blocks).slice(statesLastBlockIndex);
|
|
385
388
|
let transactions = [];
|
|
386
389
|
for (const block of blocks) {
|
|
387
|
-
|
|
390
|
+
if (block?.transactions)
|
|
391
|
+
transactions = [...transactions, ...block.transactions];
|
|
388
392
|
}
|
|
389
393
|
transactions = await Promise.all(transactions.map(async (transaction) => new TransactionMessage(await transactionStore.get(transaction))));
|
|
390
394
|
const contractsToGet = transactions.reduce((set, current) => {
|
package/exports/state.d.ts
CHANGED
|
@@ -38,7 +38,7 @@ export default class State extends Contract {
|
|
|
38
38
|
hash: string;
|
|
39
39
|
previousHash: string;
|
|
40
40
|
};
|
|
41
|
-
get lastBlockHeight(): Promise<any
|
|
41
|
+
get lastBlockHeight(): 0 | Promise<any>;
|
|
42
42
|
getBlock(index: any): Promise<any>;
|
|
43
43
|
getBlocks(from?: any, to?: any): Promise<[]>;
|
|
44
44
|
get totalSize(): number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leofcoin/chain",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.90",
|
|
4
4
|
"description": "Official javascript implementation",
|
|
5
5
|
"private": false,
|
|
6
6
|
"exports": {
|
|
@@ -61,18 +61,18 @@
|
|
|
61
61
|
"tslib": "^2.8.1"
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"@leofcoin/addresses": "^1.0.
|
|
64
|
+
"@leofcoin/addresses": "^1.0.54",
|
|
65
65
|
"@leofcoin/contracts": "^0.1.14",
|
|
66
66
|
"@leofcoin/crypto": "^0.2.37",
|
|
67
67
|
"@leofcoin/errors": "^1.0.25",
|
|
68
|
-
"@leofcoin/lib": "^1.2.
|
|
68
|
+
"@leofcoin/lib": "^1.2.72",
|
|
69
69
|
"@leofcoin/messages": "^1.4.40",
|
|
70
70
|
"@leofcoin/multi-wallet": "^3.1.8",
|
|
71
71
|
"@leofcoin/networks": "^1.1.25",
|
|
72
72
|
"@leofcoin/peernet": "^1.1.92",
|
|
73
73
|
"@leofcoin/storage": "^3.5.38",
|
|
74
74
|
"@leofcoin/utils": "^1.1.39",
|
|
75
|
-
"@leofcoin/workers": "^1.5.
|
|
75
|
+
"@leofcoin/workers": "^1.5.27",
|
|
76
76
|
"@vandeurenglenn/base58": "^1.1.9",
|
|
77
77
|
"@vandeurenglenn/easy-worker": "^1.0.2",
|
|
78
78
|
"semver": "^7.7.2"
|