Speed up mempool loop.
This commit is contained in:
parent
0177224eba
commit
ea708de9fb
@ -122,11 +122,15 @@ class Mempool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Replace mempool to clear deleted transactions
|
// Index object for faster search
|
||||||
|
const transactionsObject = {};
|
||||||
|
transactions.forEach((txId) => transactionsObject[txId] = true);
|
||||||
|
|
||||||
|
// Replace mempool to separate deleted transactions
|
||||||
const newMempool = {};
|
const newMempool = {};
|
||||||
const deletedTransactions: TransactionExtended[] = [];
|
const deletedTransactions: TransactionExtended[] = [];
|
||||||
for (const tx in this.mempoolCache) {
|
for (const tx in this.mempoolCache) {
|
||||||
if (transactions.indexOf(tx) > -1) {
|
if (transactionsObject[tx]) {
|
||||||
newMempool[tx] = this.mempoolCache[tx];
|
newMempool[tx] = this.mempoolCache[tx];
|
||||||
} else {
|
} else {
|
||||||
deletedTransactions.push(this.mempoolCache[tx]);
|
deletedTransactions.push(this.mempoolCache[tx]);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user