@leofcoin/chain 1.7.15 → 1.7.16
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 +22 -7
- package/exports/chain.js +22 -7
- package/package.json +1 -1
package/exports/browser/chain.js
CHANGED
|
@@ -5169,7 +5169,7 @@ class Chain extends VersionControl {
|
|
|
5169
5169
|
async #addBlock(block) {
|
|
5170
5170
|
const blockMessage = await new BlockMessage(block);
|
|
5171
5171
|
const hash = await blockMessage.hash();
|
|
5172
|
-
const
|
|
5172
|
+
const transactions = await Promise.all(blockMessage.decoded.transactions
|
|
5173
5173
|
// @ts-ignore
|
|
5174
5174
|
.map(async (hash) => {
|
|
5175
5175
|
let data;
|
|
@@ -5187,19 +5187,34 @@ class Chain extends VersionControl {
|
|
|
5187
5187
|
debug(`added block: ${hash}`);
|
|
5188
5188
|
let promises = [];
|
|
5189
5189
|
let contracts = [];
|
|
5190
|
-
|
|
5191
|
-
|
|
5190
|
+
const normalTransactions = [];
|
|
5191
|
+
const priorityransactions = [];
|
|
5192
|
+
for (const transaction of transactions) {
|
|
5192
5193
|
if (!contracts.includes(transaction.to)) {
|
|
5193
5194
|
contracts.push(transaction.to);
|
|
5194
5195
|
}
|
|
5195
|
-
|
|
5196
|
-
|
|
5197
|
-
|
|
5196
|
+
if (transaction.priority)
|
|
5197
|
+
priorityransactions.push(transaction);
|
|
5198
|
+
else
|
|
5199
|
+
normalTransactions.push(transaction);
|
|
5200
|
+
}
|
|
5201
|
+
for (const transaction of priorityransactions.sort((a, b) => a.decoded.nonce - b.decoded.nonce)) {
|
|
5202
|
+
await this.#handleTransaction(transaction, [], block);
|
|
5198
5203
|
}
|
|
5204
|
+
await Promise.all(normalTransactions.map((transaction) => this.#handleTransaction(transaction, [], block)));
|
|
5205
|
+
// for (let transaction of transactionsMessages) {
|
|
5206
|
+
// // await transactionStore.put(transaction.hash, transaction.encoded)
|
|
5207
|
+
// if (!contracts.includes(transaction.to)) {
|
|
5208
|
+
// contracts.push(transaction.to)
|
|
5209
|
+
// }
|
|
5210
|
+
// // Todo: go trough all accounts
|
|
5211
|
+
// //@ts-ignore
|
|
5212
|
+
// promises.push(this.#executeTransaction(transaction))
|
|
5213
|
+
// }
|
|
5199
5214
|
try {
|
|
5200
5215
|
promises = await Promise.allSettled(promises);
|
|
5201
5216
|
const noncesByAddress = {};
|
|
5202
|
-
for (let transaction of
|
|
5217
|
+
for (let transaction of transactions) {
|
|
5203
5218
|
globalThis.pubsub.publish('transaction-processed', transaction);
|
|
5204
5219
|
if (transaction.to === globalThis.peernet.selectedAccount)
|
|
5205
5220
|
globalThis.pubsub.publish('account-transaction-processed', transaction);
|
package/exports/chain.js
CHANGED
|
@@ -1536,7 +1536,7 @@ class Chain extends VersionControl {
|
|
|
1536
1536
|
async #addBlock(block) {
|
|
1537
1537
|
const blockMessage = await new BlockMessage(block);
|
|
1538
1538
|
const hash = await blockMessage.hash();
|
|
1539
|
-
const
|
|
1539
|
+
const transactions = await Promise.all(blockMessage.decoded.transactions
|
|
1540
1540
|
// @ts-ignore
|
|
1541
1541
|
.map(async (hash) => {
|
|
1542
1542
|
let data;
|
|
@@ -1554,19 +1554,34 @@ class Chain extends VersionControl {
|
|
|
1554
1554
|
debug(`added block: ${hash}`);
|
|
1555
1555
|
let promises = [];
|
|
1556
1556
|
let contracts = [];
|
|
1557
|
-
|
|
1558
|
-
|
|
1557
|
+
const normalTransactions = [];
|
|
1558
|
+
const priorityransactions = [];
|
|
1559
|
+
for (const transaction of transactions) {
|
|
1559
1560
|
if (!contracts.includes(transaction.to)) {
|
|
1560
1561
|
contracts.push(transaction.to);
|
|
1561
1562
|
}
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1563
|
+
if (transaction.priority)
|
|
1564
|
+
priorityransactions.push(transaction);
|
|
1565
|
+
else
|
|
1566
|
+
normalTransactions.push(transaction);
|
|
1567
|
+
}
|
|
1568
|
+
for (const transaction of priorityransactions.sort((a, b) => a.decoded.nonce - b.decoded.nonce)) {
|
|
1569
|
+
await this.#handleTransaction(transaction, [], block);
|
|
1565
1570
|
}
|
|
1571
|
+
await Promise.all(normalTransactions.map((transaction) => this.#handleTransaction(transaction, [], block)));
|
|
1572
|
+
// for (let transaction of transactionsMessages) {
|
|
1573
|
+
// // await transactionStore.put(transaction.hash, transaction.encoded)
|
|
1574
|
+
// if (!contracts.includes(transaction.to)) {
|
|
1575
|
+
// contracts.push(transaction.to)
|
|
1576
|
+
// }
|
|
1577
|
+
// // Todo: go trough all accounts
|
|
1578
|
+
// //@ts-ignore
|
|
1579
|
+
// promises.push(this.#executeTransaction(transaction))
|
|
1580
|
+
// }
|
|
1566
1581
|
try {
|
|
1567
1582
|
promises = await Promise.allSettled(promises);
|
|
1568
1583
|
const noncesByAddress = {};
|
|
1569
|
-
for (let transaction of
|
|
1584
|
+
for (let transaction of transactions) {
|
|
1570
1585
|
globalThis.pubsub.publish('transaction-processed', transaction);
|
|
1571
1586
|
if (transaction.to === globalThis.peernet.selectedAccount)
|
|
1572
1587
|
globalThis.pubsub.publish('account-transaction-processed', transaction);
|