@leofcoin/chain 1.5.58 → 1.5.59
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
CHANGED
|
@@ -4938,9 +4938,12 @@ class Chain extends VersionControl {
|
|
|
4938
4938
|
// @ts-ignore
|
|
4939
4939
|
.map(async (transaction) => {
|
|
4940
4940
|
let hash = transaction.hash;
|
|
4941
|
-
if (!hash)
|
|
4942
|
-
await new TransactionMessage(transaction).hash();
|
|
4941
|
+
if (!hash) {
|
|
4942
|
+
hash = await new TransactionMessage(transaction).hash();
|
|
4943
|
+
transaction.hash = hash;
|
|
4944
|
+
}
|
|
4943
4945
|
(await transactionPoolStore.has(hash)) && (await transactionPoolStore.delete(hash));
|
|
4946
|
+
return transaction;
|
|
4944
4947
|
}));
|
|
4945
4948
|
const hash = await blockMessage.hash();
|
|
4946
4949
|
await globalThis.blockStore.put(hash, blockMessage.encoded);
|
|
@@ -4951,13 +4954,11 @@ class Chain extends VersionControl {
|
|
|
4951
4954
|
let contracts = [];
|
|
4952
4955
|
for (let transaction of blockMessage.decoded.transactions) {
|
|
4953
4956
|
// await transactionStore.put(transaction.hash, transaction.encoded)
|
|
4954
|
-
|
|
4955
|
-
const index = contracts.indexOf(transaction.to);
|
|
4956
|
-
// @ts-ignore
|
|
4957
|
-
if (index === -1)
|
|
4957
|
+
if (!contracts.includes(transaction.to)) {
|
|
4958
4958
|
contracts.push(transaction.to);
|
|
4959
|
+
}
|
|
4959
4960
|
// Todo: go trough all accounts
|
|
4960
|
-
|
|
4961
|
+
//@ts-ignore
|
|
4961
4962
|
promises.push(this.#executeTransaction(transaction));
|
|
4962
4963
|
}
|
|
4963
4964
|
try {
|
|
@@ -147,15 +147,14 @@ _.init = async (message) => {
|
|
|
147
147
|
|
|
148
148
|
// }
|
|
149
149
|
for (const block of blocks) {
|
|
150
|
-
// we only revalidate the latest
|
|
151
|
-
// every
|
|
150
|
+
// we only revalidate the latest 24 blocks
|
|
151
|
+
// every 24 blocks a snapshot is taken and stored in state
|
|
152
152
|
// this means contracts will be restored from this state
|
|
153
153
|
// this also means devs NEED to make sure the state can be restored
|
|
154
154
|
// on contract deploy an error will be thrown if state wasn't recoverable
|
|
155
|
-
if (block.index >
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
}
|
|
155
|
+
if (block.index > 24) {
|
|
156
|
+
const transactionCount = blocks[block.index - 1].transactions.length;
|
|
157
|
+
latestTransactions.splice(-(transactionCount - 1), latestTransactions.length);
|
|
159
158
|
}
|
|
160
159
|
await Promise.all(
|
|
161
160
|
block.transactions.map(async (transaction) => {
|
package/exports/chain.js
CHANGED
|
@@ -1349,9 +1349,12 @@ class Chain extends VersionControl {
|
|
|
1349
1349
|
// @ts-ignore
|
|
1350
1350
|
.map(async (transaction) => {
|
|
1351
1351
|
let hash = transaction.hash;
|
|
1352
|
-
if (!hash)
|
|
1353
|
-
await new TransactionMessage(transaction).hash();
|
|
1352
|
+
if (!hash) {
|
|
1353
|
+
hash = await new TransactionMessage(transaction).hash();
|
|
1354
|
+
transaction.hash = hash;
|
|
1355
|
+
}
|
|
1354
1356
|
(await transactionPoolStore.has(hash)) && (await transactionPoolStore.delete(hash));
|
|
1357
|
+
return transaction;
|
|
1355
1358
|
}));
|
|
1356
1359
|
const hash = await blockMessage.hash();
|
|
1357
1360
|
await globalThis.blockStore.put(hash, blockMessage.encoded);
|
|
@@ -1362,13 +1365,11 @@ class Chain extends VersionControl {
|
|
|
1362
1365
|
let contracts = [];
|
|
1363
1366
|
for (let transaction of blockMessage.decoded.transactions) {
|
|
1364
1367
|
// await transactionStore.put(transaction.hash, transaction.encoded)
|
|
1365
|
-
|
|
1366
|
-
const index = contracts.indexOf(transaction.to);
|
|
1367
|
-
// @ts-ignore
|
|
1368
|
-
if (index === -1)
|
|
1368
|
+
if (!contracts.includes(transaction.to)) {
|
|
1369
1369
|
contracts.push(transaction.to);
|
|
1370
|
+
}
|
|
1370
1371
|
// Todo: go trough all accounts
|
|
1371
|
-
|
|
1372
|
+
//@ts-ignore
|
|
1372
1373
|
promises.push(this.#executeTransaction(transaction));
|
|
1373
1374
|
}
|
|
1374
1375
|
try {
|
|
@@ -147,15 +147,14 @@ _.init = async (message) => {
|
|
|
147
147
|
|
|
148
148
|
// }
|
|
149
149
|
for (const block of blocks) {
|
|
150
|
-
// we only revalidate the latest
|
|
151
|
-
// every
|
|
150
|
+
// we only revalidate the latest 24 blocks
|
|
151
|
+
// every 24 blocks a snapshot is taken and stored in state
|
|
152
152
|
// this means contracts will be restored from this state
|
|
153
153
|
// this also means devs NEED to make sure the state can be restored
|
|
154
154
|
// on contract deploy an error will be thrown if state wasn't recoverable
|
|
155
|
-
if (block.index >
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
}
|
|
155
|
+
if (block.index > 24) {
|
|
156
|
+
const transactionCount = blocks[block.index - 1].transactions.length;
|
|
157
|
+
latestTransactions.splice(-(transactionCount - 1), latestTransactions.length);
|
|
159
158
|
}
|
|
160
159
|
await Promise.all(
|
|
161
160
|
block.transactions.map(async (transaction) => {
|