From 96b457d47e9d649758683926eadd4a9f7c0e2f96 Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Wed, 5 Apr 2017 08:36:34 +0200 Subject: [PATCH] Merge #10144: Prioritisetransaction wasn't always updating ancestor fee 9bef02e Bugfix: ancestor modifed fees were incorrect for descendants (Suhas Daftuar) ba7dd8b Test prioritisetransaction and ancestor fee state (Suhas Daftuar) Tree-SHA512: 01977d88e1afb093a003f22a6f29ea60df3d70a179fe7e55910b9c8c340c4af9fb20cdc804c40235b62c43c453f0194eda0d0d4dbd365d2d98347f5dbe5de01c --- qa/rpc-tests/mempool_packages.py | 12 ++++++++++++ src/txmempool.cpp | 7 +++++++ 2 files changed, 19 insertions(+) diff --git a/qa/rpc-tests/mempool_packages.py b/qa/rpc-tests/mempool_packages.py index f605e7524..f53515d32 100755 --- a/qa/rpc-tests/mempool_packages.py +++ b/qa/rpc-tests/mempool_packages.py @@ -102,6 +102,18 @@ class MempoolPackagesTest(BitcoinTestFramework): assert_equal(mempool[x], v_descendants[x]) assert(chain[0] not in v_descendants.keys()) + # Check that ancestor modified fees includes fee deltas from + # prioritisetransaction + self.nodes[0].prioritisetransaction(chain[0], 1000) + mempool = self.nodes[0].getrawmempool(True) + ancestor_fees = 0 + for x in chain: + ancestor_fees += mempool[x]['fee'] + assert_equal(mempool[x]['ancestorfees'], ancestor_fees * COIN + 1000) + + # Undo the prioritisetransaction for later tests + self.nodes[0].prioritisetransaction(chain[0], -1000) + # Check that descendant modified fees includes fee deltas from # prioritisetransaction self.nodes[0].prioritisetransaction(chain[-1], 0, 1000) diff --git a/src/txmempool.cpp b/src/txmempool.cpp index 405258533..1bd8d7c23 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -1073,6 +1073,13 @@ void CTxMemPool::PrioritiseTransaction(const uint256 hash, const std::string str BOOST_FOREACH(txiter ancestorIt, setAncestors) { mapTx.modify(ancestorIt, update_descendant_state(0, nFeeDelta, 0)); } + // Now update all descendants' modified fees with ancestors + setEntries setDescendants; + CalculateDescendants(it, setDescendants); + setDescendants.erase(it); + BOOST_FOREACH(txiter descendantIt, setDescendants) { + mapTx.modify(descendantIt, update_ancestor_state(0, nFeeDelta, 0, 0)); + } } } LogPrintf("PrioritiseTransaction: %s priority += %f, fee += %d\n", strHash, dPriorityDelta, FormatMoney(nFeeDelta));