@leofcoin/chain 1.7.16 → 1.7.18
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 +17 -7
- package/exports/chain.js +17 -7
- package/package.json +1 -1
package/exports/browser/chain.js
CHANGED
|
@@ -4568,6 +4568,15 @@ class State extends Contract {
|
|
|
4568
4568
|
}
|
|
4569
4569
|
try {
|
|
4570
4570
|
const block = await this.getAndPutBlock(hash);
|
|
4571
|
+
await Promise.all(block.decoded.transactions.map(async (hash) => {
|
|
4572
|
+
// should be in a transaction store already
|
|
4573
|
+
if (!(await transactionStore.has(hash))) {
|
|
4574
|
+
const data = await peernet.get(hash, 'transaction');
|
|
4575
|
+
await transactionStore.put(hash, data);
|
|
4576
|
+
}
|
|
4577
|
+
;
|
|
4578
|
+
(await transactionPoolStore.has(hash)) && (await transactionPoolStore.delete(hash));
|
|
4579
|
+
}));
|
|
4571
4580
|
index = block.decoded.index;
|
|
4572
4581
|
const size = block.encoded.length > 0 ? block.encoded.length : block.encoded.byteLength;
|
|
4573
4582
|
this.#totalSize += size;
|
|
@@ -5181,7 +5190,7 @@ class Chain extends VersionControl {
|
|
|
5181
5190
|
data = transactionStore.get(hash);
|
|
5182
5191
|
}
|
|
5183
5192
|
(await transactionPoolStore.has(hash)) && (await transactionPoolStore.delete(hash));
|
|
5184
|
-
return new TransactionMessage(data)
|
|
5193
|
+
return new TransactionMessage(data);
|
|
5185
5194
|
}));
|
|
5186
5195
|
await globalThis.blockStore.put(hash, blockMessage.encoded);
|
|
5187
5196
|
debug(`added block: ${hash}`);
|
|
@@ -5190,10 +5199,10 @@ class Chain extends VersionControl {
|
|
|
5190
5199
|
const normalTransactions = [];
|
|
5191
5200
|
const priorityransactions = [];
|
|
5192
5201
|
for (const transaction of transactions) {
|
|
5193
|
-
if (!contracts.includes(transaction.to)) {
|
|
5194
|
-
contracts.push(transaction.to);
|
|
5202
|
+
if (!contracts.includes(transaction.decoded.to)) {
|
|
5203
|
+
contracts.push(transaction.decoded.to);
|
|
5195
5204
|
}
|
|
5196
|
-
if (transaction.priority)
|
|
5205
|
+
if (transaction.decoded.priority)
|
|
5197
5206
|
priorityransactions.push(transaction);
|
|
5198
5207
|
else
|
|
5199
5208
|
normalTransactions.push(transaction);
|
|
@@ -5216,10 +5225,11 @@ class Chain extends VersionControl {
|
|
|
5216
5225
|
const noncesByAddress = {};
|
|
5217
5226
|
for (let transaction of transactions) {
|
|
5218
5227
|
globalThis.pubsub.publish('transaction-processed', transaction);
|
|
5219
|
-
if (transaction.to === globalThis.peernet.selectedAccount)
|
|
5228
|
+
if (transaction.decoded.to === globalThis.peernet.selectedAccount)
|
|
5220
5229
|
globalThis.pubsub.publish('account-transaction-processed', transaction);
|
|
5221
|
-
if (!noncesByAddress[transaction.from] ||
|
|
5222
|
-
noncesByAddress[transaction.from]
|
|
5230
|
+
if (!noncesByAddress[transaction.decoded.from] ||
|
|
5231
|
+
noncesByAddress?.[transaction.decoded.from] < transaction.decoded.nonce) {
|
|
5232
|
+
noncesByAddress[transaction.decoded.from] = transaction.decoded.nonce;
|
|
5223
5233
|
}
|
|
5224
5234
|
}
|
|
5225
5235
|
await Promise.all(Object.entries(noncesByAddress).map(([from, nonce]) => globalThis.accountsStore.put(from, String(nonce))));
|
package/exports/chain.js
CHANGED
|
@@ -935,6 +935,15 @@ class State extends Contract {
|
|
|
935
935
|
}
|
|
936
936
|
try {
|
|
937
937
|
const block = await this.getAndPutBlock(hash);
|
|
938
|
+
await Promise.all(block.decoded.transactions.map(async (hash) => {
|
|
939
|
+
// should be in a transaction store already
|
|
940
|
+
if (!(await transactionStore.has(hash))) {
|
|
941
|
+
const data = await peernet.get(hash, 'transaction');
|
|
942
|
+
await transactionStore.put(hash, data);
|
|
943
|
+
}
|
|
944
|
+
;
|
|
945
|
+
(await transactionPoolStore.has(hash)) && (await transactionPoolStore.delete(hash));
|
|
946
|
+
}));
|
|
938
947
|
index = block.decoded.index;
|
|
939
948
|
const size = block.encoded.length > 0 ? block.encoded.length : block.encoded.byteLength;
|
|
940
949
|
this.#totalSize += size;
|
|
@@ -1548,7 +1557,7 @@ class Chain extends VersionControl {
|
|
|
1548
1557
|
data = transactionStore.get(hash);
|
|
1549
1558
|
}
|
|
1550
1559
|
(await transactionPoolStore.has(hash)) && (await transactionPoolStore.delete(hash));
|
|
1551
|
-
return new TransactionMessage(data)
|
|
1560
|
+
return new TransactionMessage(data);
|
|
1552
1561
|
}));
|
|
1553
1562
|
await globalThis.blockStore.put(hash, blockMessage.encoded);
|
|
1554
1563
|
debug(`added block: ${hash}`);
|
|
@@ -1557,10 +1566,10 @@ class Chain extends VersionControl {
|
|
|
1557
1566
|
const normalTransactions = [];
|
|
1558
1567
|
const priorityransactions = [];
|
|
1559
1568
|
for (const transaction of transactions) {
|
|
1560
|
-
if (!contracts.includes(transaction.to)) {
|
|
1561
|
-
contracts.push(transaction.to);
|
|
1569
|
+
if (!contracts.includes(transaction.decoded.to)) {
|
|
1570
|
+
contracts.push(transaction.decoded.to);
|
|
1562
1571
|
}
|
|
1563
|
-
if (transaction.priority)
|
|
1572
|
+
if (transaction.decoded.priority)
|
|
1564
1573
|
priorityransactions.push(transaction);
|
|
1565
1574
|
else
|
|
1566
1575
|
normalTransactions.push(transaction);
|
|
@@ -1583,10 +1592,11 @@ class Chain extends VersionControl {
|
|
|
1583
1592
|
const noncesByAddress = {};
|
|
1584
1593
|
for (let transaction of transactions) {
|
|
1585
1594
|
globalThis.pubsub.publish('transaction-processed', transaction);
|
|
1586
|
-
if (transaction.to === globalThis.peernet.selectedAccount)
|
|
1595
|
+
if (transaction.decoded.to === globalThis.peernet.selectedAccount)
|
|
1587
1596
|
globalThis.pubsub.publish('account-transaction-processed', transaction);
|
|
1588
|
-
if (!noncesByAddress[transaction.from] ||
|
|
1589
|
-
noncesByAddress[transaction.from]
|
|
1597
|
+
if (!noncesByAddress[transaction.decoded.from] ||
|
|
1598
|
+
noncesByAddress?.[transaction.decoded.from] < transaction.decoded.nonce) {
|
|
1599
|
+
noncesByAddress[transaction.decoded.from] = transaction.decoded.nonce;
|
|
1590
1600
|
}
|
|
1591
1601
|
}
|
|
1592
1602
|
await Promise.all(Object.entries(noncesByAddress).map(([from, nonce]) => globalThis.accountsStore.put(from, String(nonce))));
|