MCPcopy Create free account
hub / github.com/ElementsProject/elements / CompareDepthAndScore

Method CompareDepthAndScore

src/txmempool.cpp:923–941  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

921}
922
923bool CTxMemPool::CompareDepthAndScore(const uint256& hasha, const uint256& hashb, bool wtxid)
924{
925 /* Return `true` if hasha should be considered sooner than hashb. Namely when:
926 * a is not in the mempool, but b is
927 * both are in the mempool and a has fewer ancestors than b
928 * both are in the mempool and a has a higher score than b
929 */
930 LOCK(cs);
931 indexed_transaction_set::const_iterator j = wtxid ? get_iter_from_wtxid(hashb) : mapTx.find(hashb);
932 if (j == mapTx.end()) return false;
933 indexed_transaction_set::const_iterator i = wtxid ? get_iter_from_wtxid(hasha) : mapTx.find(hasha);
934 if (i == mapTx.end()) return true;
935 uint64_t counta = i->GetCountWithAncestors();
936 uint64_t countb = j->GetCountWithAncestors();
937 if (counta == countb) {
938 return CompareTxMemPoolEntryByScore()(*i, *j);
939 }
940 return counta < countb;
941}
942
943namespace {
944class DepthAndScoreComparator

Callers 1

operator()Method · 0.80

Calls 4

findMethod · 0.80
GetCountWithAncestorsMethod · 0.80
endMethod · 0.45

Tested by

no test coverage detected