mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-03 09:56:38 -05:00
txmempool: have CompareDepthAndScore sort missing txs first
We use CompareDepthAndScore to choose an order of txs to inv. Rather than sorting txs that have been evicted from the mempool at the end of the list, sort them at the beginning so they are removed from the queue immediately.
This commit is contained in:
parent
fc06881f13
commit
228e9201ef
1 changed files with 8 additions and 3 deletions
|
@ -755,11 +755,16 @@ void CTxMemPool::check(const CCoinsViewCache& active_coins_tip, int64_t spendhei
|
|||
|
||||
bool CTxMemPool::CompareDepthAndScore(const uint256& hasha, const uint256& hashb, bool wtxid)
|
||||
{
|
||||
/* Return `true` if hasha should be considered sooner than hashb. Namely when:
|
||||
* a is not in the mempool, but b is
|
||||
* both are in the mempool and a has fewer ancestors than b
|
||||
* both are in the mempool and a has a higher score than b
|
||||
*/
|
||||
LOCK(cs);
|
||||
indexed_transaction_set::const_iterator i = wtxid ? get_iter_from_wtxid(hasha) : mapTx.find(hasha);
|
||||
if (i == mapTx.end()) return false;
|
||||
indexed_transaction_set::const_iterator j = wtxid ? get_iter_from_wtxid(hashb) : mapTx.find(hashb);
|
||||
if (j == mapTx.end()) return true;
|
||||
if (j == mapTx.end()) return false;
|
||||
indexed_transaction_set::const_iterator i = wtxid ? get_iter_from_wtxid(hasha) : mapTx.find(hasha);
|
||||
if (i == mapTx.end()) return true;
|
||||
uint64_t counta = i->GetCountWithAncestors();
|
||||
uint64_t countb = j->GetCountWithAncestors();
|
||||
if (counta == countb) {
|
||||
|
|
Loading…
Add table
Reference in a new issue