move new tx selection algorithm into thread worker

This commit is contained in:
Mononaut
2022-11-16 18:17:07 -06:00
parent 38cb45e026
commit 08ad6a0da3
3 changed files with 366 additions and 292 deletions

View File

@@ -417,10 +417,9 @@ class WebsocketHandler {
const _memPool = memPool.getMempool();
if (Common.indexingEnabled() && memPool.isInSync()) {
const mempoolCopy = cloneMempool(_memPool);
const projectedBlocks = mempoolBlocks.makeBlockTemplates(mempoolCopy, 2);
const projectedBlocks = mempoolBlocks.getMempoolBlocksWithTransactions();
const { censored, added, score } = Audit.auditBlock(transactions, projectedBlocks, mempoolCopy);
const { censored, added, score } = Audit.auditBlock(transactions, projectedBlocks, _memPool);
matchRate = Math.round(score * 100 * 100) / 100;
const stripped = projectedBlocks[0]?.transactions ? projectedBlocks[0].transactions.map((tx) => {
@@ -569,14 +568,4 @@ class WebsocketHandler {
}
}
function cloneMempool(mempool: { [txid: string]: TransactionExtended }): { [txid: string]: TransactionExtended } {
const cloned = {};
Object.keys(mempool).forEach(id => {
cloned[id] = {
...mempool[id]
};
});
return cloned;
}
export default new WebsocketHandler();