aboutsummaryrefslogtreecommitdiff
path: root/src/txmempool.cpp
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2016-04-10 15:33:05 +0200
committerPieter Wuille <pieter.wuille@gmail.com>2016-04-21 00:33:56 +0200
commit4578215e7f787968c1d6478e6df75499bd36dd8d (patch)
tree402c14568a452dda1b7dc3a2c88cc47326ba88f9 /src/txmempool.cpp
parented7068302c7490e8061cb3a558a0f83a465beeea (diff)
downloadbitcoin-4578215e7f787968c1d6478e6df75499bd36dd8d.tar.xz
Return mempool queries in dependency order
Diffstat (limited to 'src/txmempool.cpp')
-rw-r--r--src/txmempool.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/txmempool.cpp b/src/txmempool.cpp
index 3aba578fac..0d9fcc982d 100644
--- a/src/txmempool.cpp
+++ b/src/txmempool.cpp
@@ -767,6 +767,16 @@ bool CTxMemPool::CompareDepthAndScore(const uint256& hasha, const uint256& hashb
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();
@@ -775,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