Merge #7840: Several performance and privacy improvements to inv/mempool handling
b559914Move bloom and feerate filtering to just prior to tx sending. (Gregory Maxwell)4578215Return mempool queries in dependency order (Pieter Wuille)ed70683Handle mempool requests in send loop, subject to trickle (Pieter Wuille)dc13dcdSplit up and optimize transaction and block inv queues (Pieter Wuille)f2d3ba7Eliminate TX trickle bypass, sort TX invs for privacy and priority. (Gregory Maxwell)
This commit is contained in:
@@ -752,6 +752,31 @@ void CTxMemPool::check(const CCoinsViewCache *pcoins) const
|
||||
assert(innerUsage == cachedInnerUsage);
|
||||
}
|
||||
|
||||
bool CTxMemPool::CompareDepthAndScore(const uint256& hasha, const uint256& hashb)
|
||||
{
|
||||
LOCK(cs);
|
||||
indexed_transaction_set::const_iterator i = mapTx.find(hasha);
|
||||
if (i == mapTx.end()) return false;
|
||||
indexed_transaction_set::const_iterator j = mapTx.find(hashb);
|
||||
if (j == mapTx.end()) return true;
|
||||
uint64_t counta = i->GetCountWithAncestors();
|
||||
uint64_t countb = j->GetCountWithAncestors();
|
||||
if (counta == countb) {
|
||||
return CompareTxMemPoolEntryByScore()(*i, *j);
|
||||
}
|
||||
return counta < countb;
|
||||
}
|
||||
|
||||
namespace {
|
||||
class DepthAndScoreComparator
|
||||
{
|
||||
CTxMemPool *mp;
|
||||
public:
|
||||
DepthAndScoreComparator(CTxMemPool *mempool) : mp(mempool) {}
|
||||
bool operator()(const uint256& a, const uint256& b) { return mp->CompareDepthAndScore(a, b); }
|
||||
};
|
||||
}
|
||||
|
||||
void CTxMemPool::queryHashes(vector<uint256>& vtxid)
|
||||
{
|
||||
vtxid.clear();
|
||||
@@ -760,6 +785,8 @@ void CTxMemPool::queryHashes(vector<uint256>& vtxid)
|
||||
vtxid.reserve(mapTx.size());
|
||||
for (indexed_transaction_set::iterator mi = mapTx.begin(); mi != mapTx.end(); ++mi)
|
||||
vtxid.push_back(mi->GetTx().GetHash());
|
||||
|
||||
std::sort(vtxid.begin(), vtxid.end(), DepthAndScoreComparator(this));
|
||||
}
|
||||
|
||||
bool CTxMemPool::lookup(uint256 hash, CTransaction& result) const
|
||||
|
||||
Reference in New Issue
Block a user