@leofcoin/chain 1.7.17 → 1.7.19
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 +11 -15
- package/exports/chain.js +11 -15
- package/package.json +1 -1
package/exports/browser/chain.js
CHANGED
|
@@ -5181,16 +5181,10 @@ class Chain extends VersionControl {
|
|
|
5181
5181
|
const transactions = await Promise.all(blockMessage.decoded.transactions
|
|
5182
5182
|
// @ts-ignore
|
|
5183
5183
|
.map(async (hash) => {
|
|
5184
|
-
|
|
5185
|
-
|
|
5186
|
-
data = await peernet.get(hash, 'transaction');
|
|
5187
|
-
transactionStore.put(hash, data);
|
|
5188
|
-
}
|
|
5189
|
-
else {
|
|
5190
|
-
data = transactionStore.get(hash);
|
|
5191
|
-
}
|
|
5184
|
+
const data = await peernet.get(hash, 'transaction');
|
|
5185
|
+
transactionStore.put(hash, data);
|
|
5192
5186
|
(await transactionPoolStore.has(hash)) && (await transactionPoolStore.delete(hash));
|
|
5193
|
-
return new TransactionMessage(data)
|
|
5187
|
+
return new TransactionMessage(data);
|
|
5194
5188
|
}));
|
|
5195
5189
|
await globalThis.blockStore.put(hash, blockMessage.encoded);
|
|
5196
5190
|
debug(`added block: ${hash}`);
|
|
@@ -5199,10 +5193,10 @@ class Chain extends VersionControl {
|
|
|
5199
5193
|
const normalTransactions = [];
|
|
5200
5194
|
const priorityransactions = [];
|
|
5201
5195
|
for (const transaction of transactions) {
|
|
5202
|
-
if (!contracts.includes(transaction.to)) {
|
|
5203
|
-
contracts.push(transaction.to);
|
|
5196
|
+
if (!contracts.includes(transaction.decoded.to)) {
|
|
5197
|
+
contracts.push(transaction.decoded.to);
|
|
5204
5198
|
}
|
|
5205
|
-
if (transaction.priority)
|
|
5199
|
+
if (transaction.decoded.priority)
|
|
5206
5200
|
priorityransactions.push(transaction);
|
|
5207
5201
|
else
|
|
5208
5202
|
normalTransactions.push(transaction);
|
|
@@ -5225,10 +5219,11 @@ class Chain extends VersionControl {
|
|
|
5225
5219
|
const noncesByAddress = {};
|
|
5226
5220
|
for (let transaction of transactions) {
|
|
5227
5221
|
globalThis.pubsub.publish('transaction-processed', transaction);
|
|
5228
|
-
if (transaction.to === globalThis.peernet.selectedAccount)
|
|
5222
|
+
if (transaction.decoded.to === globalThis.peernet.selectedAccount)
|
|
5229
5223
|
globalThis.pubsub.publish('account-transaction-processed', transaction);
|
|
5230
|
-
if (!noncesByAddress[transaction.from] ||
|
|
5231
|
-
noncesByAddress[transaction.from]
|
|
5224
|
+
if (!noncesByAddress[transaction.decoded.from] ||
|
|
5225
|
+
noncesByAddress?.[transaction.decoded.from] < transaction.decoded.nonce) {
|
|
5226
|
+
noncesByAddress[transaction.decoded.from] = transaction.decoded.nonce;
|
|
5232
5227
|
}
|
|
5233
5228
|
}
|
|
5234
5229
|
await Promise.all(Object.entries(noncesByAddress).map(([from, nonce]) => globalThis.accountsStore.put(from, String(nonce))));
|
|
@@ -5284,6 +5279,7 @@ class Chain extends VersionControl {
|
|
|
5284
5279
|
block.transactions.push(hash);
|
|
5285
5280
|
block.fees = block.fees.add(await calculateFee(transaction.decoded));
|
|
5286
5281
|
await globalThis.accountsStore.put(transaction.decoded.from, new TextEncoder().encode(String(transaction.decoded.nonce)));
|
|
5282
|
+
await transactionStore.put(hash, await transaction.encode());
|
|
5287
5283
|
}
|
|
5288
5284
|
catch (e) {
|
|
5289
5285
|
console.log('vvvvvv');
|
package/exports/chain.js
CHANGED
|
@@ -1548,16 +1548,10 @@ class Chain extends VersionControl {
|
|
|
1548
1548
|
const transactions = await Promise.all(blockMessage.decoded.transactions
|
|
1549
1549
|
// @ts-ignore
|
|
1550
1550
|
.map(async (hash) => {
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
data = await peernet.get(hash, 'transaction');
|
|
1554
|
-
transactionStore.put(hash, data);
|
|
1555
|
-
}
|
|
1556
|
-
else {
|
|
1557
|
-
data = transactionStore.get(hash);
|
|
1558
|
-
}
|
|
1551
|
+
const data = await peernet.get(hash, 'transaction');
|
|
1552
|
+
transactionStore.put(hash, data);
|
|
1559
1553
|
(await transactionPoolStore.has(hash)) && (await transactionPoolStore.delete(hash));
|
|
1560
|
-
return new TransactionMessage(data)
|
|
1554
|
+
return new TransactionMessage(data);
|
|
1561
1555
|
}));
|
|
1562
1556
|
await globalThis.blockStore.put(hash, blockMessage.encoded);
|
|
1563
1557
|
debug(`added block: ${hash}`);
|
|
@@ -1566,10 +1560,10 @@ class Chain extends VersionControl {
|
|
|
1566
1560
|
const normalTransactions = [];
|
|
1567
1561
|
const priorityransactions = [];
|
|
1568
1562
|
for (const transaction of transactions) {
|
|
1569
|
-
if (!contracts.includes(transaction.to)) {
|
|
1570
|
-
contracts.push(transaction.to);
|
|
1563
|
+
if (!contracts.includes(transaction.decoded.to)) {
|
|
1564
|
+
contracts.push(transaction.decoded.to);
|
|
1571
1565
|
}
|
|
1572
|
-
if (transaction.priority)
|
|
1566
|
+
if (transaction.decoded.priority)
|
|
1573
1567
|
priorityransactions.push(transaction);
|
|
1574
1568
|
else
|
|
1575
1569
|
normalTransactions.push(transaction);
|
|
@@ -1592,10 +1586,11 @@ class Chain extends VersionControl {
|
|
|
1592
1586
|
const noncesByAddress = {};
|
|
1593
1587
|
for (let transaction of transactions) {
|
|
1594
1588
|
globalThis.pubsub.publish('transaction-processed', transaction);
|
|
1595
|
-
if (transaction.to === globalThis.peernet.selectedAccount)
|
|
1589
|
+
if (transaction.decoded.to === globalThis.peernet.selectedAccount)
|
|
1596
1590
|
globalThis.pubsub.publish('account-transaction-processed', transaction);
|
|
1597
|
-
if (!noncesByAddress[transaction.from] ||
|
|
1598
|
-
noncesByAddress[transaction.from]
|
|
1591
|
+
if (!noncesByAddress[transaction.decoded.from] ||
|
|
1592
|
+
noncesByAddress?.[transaction.decoded.from] < transaction.decoded.nonce) {
|
|
1593
|
+
noncesByAddress[transaction.decoded.from] = transaction.decoded.nonce;
|
|
1599
1594
|
}
|
|
1600
1595
|
}
|
|
1601
1596
|
await Promise.all(Object.entries(noncesByAddress).map(([from, nonce]) => globalThis.accountsStore.put(from, String(nonce))));
|
|
@@ -1651,6 +1646,7 @@ class Chain extends VersionControl {
|
|
|
1651
1646
|
block.transactions.push(hash);
|
|
1652
1647
|
block.fees = block.fees.add(await calculateFee(transaction.decoded));
|
|
1653
1648
|
await globalThis.accountsStore.put(transaction.decoded.from, new TextEncoder().encode(String(transaction.decoded.nonce)));
|
|
1649
|
+
await transactionStore.put(hash, await transaction.encode());
|
|
1654
1650
|
}
|
|
1655
1651
|
catch (e) {
|
|
1656
1652
|
console.log('vvvvvv');
|