move new tx selection algorithm into thread worker

This commit is contained in:
Mononaut committed 2022-11-22 14:43:55 +09:00
1 parent dd8b05f672
commit 433f930b0e
3 files changed
+366 -292

No files matched your search

+2 -13
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();