From acc2e4bc96ed705aed3b331141028f7b838eccbe Mon Sep 17 00:00:00 2001 From: Suhas Daftuar Date: Mon, 3 Apr 2017 16:31:51 -0400 Subject: [PATCH 1/2] Bugfix: PrioritiseTransaction updates the mempool tx counter The mempool's nTransactionsUpdated is used by getblocktemplate to trigger new invocations of CreateNewBlock(). --- src/txmempool.cpp | 1 + src/txmempool.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/txmempool.cpp b/src/txmempool.cpp index ac842da6bf3..0fead800733 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -865,6 +865,7 @@ void CTxMemPool::PrioritiseTransaction(const uint256& hash, const CAmount& nFeeD BOOST_FOREACH(txiter descendantIt, setDescendants) { mapTx.modify(descendantIt, update_ancestor_state(0, nFeeDelta, 0, 0)); } + ++nTransactionsUpdated; } } LogPrintf("PrioritiseTransaction: %s feerate += %s\n", hash.ToString(), FormatMoney(nFeeDelta)); diff --git a/src/txmempool.h b/src/txmempool.h index 92c4d9f9d47..9fb8c40e1f4 100644 --- a/src/txmempool.h +++ b/src/txmempool.h @@ -411,7 +411,7 @@ class CTxMemPool { private: uint32_t nCheckFrequency; //!< Value n means that n times in 2^32 we check. - unsigned int nTransactionsUpdated; + unsigned int nTransactionsUpdated; //!< Used by getblocktemplate to trigger CreateNewBlock() invocation CBlockPolicyEstimator* minerPolicyEstimator; uint64_t totalTxSize; //!< sum of all mempool tx's virtual sizes. Differs from serialized tx size since witness data is discounted. Defined in BIP 141. From 6c2e25caf6b6e55bbb4161f815f1c6402ac10d10 Mon Sep 17 00:00:00 2001 From: Suhas Daftuar Date: Tue, 18 Apr 2017 12:52:08 -0400 Subject: [PATCH 2/2] [qa] Test prioritise_transaction / getblocktemplate interaction --- test/functional/prioritise_transaction.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/test/functional/prioritise_transaction.py b/test/functional/prioritise_transaction.py index a07923edba8..9c3b3fd5d9b 100755 --- a/test/functional/prioritise_transaction.py +++ b/test/functional/prioritise_transaction.py @@ -13,8 +13,8 @@ class PrioritiseTransactionTest(BitcoinTestFramework): def __init__(self): super().__init__() self.setup_clean_chain = True - self.num_nodes = 1 - self.extra_args = [["-printpriority=1"]] + self.num_nodes = 2 + self.extra_args = [["-printpriority=1"], ["-printpriority=1"]] def run_test(self): self.txouts = gen_return_txouts() @@ -115,5 +115,16 @@ class PrioritiseTransactionTest(BitcoinTestFramework): assert_equal(self.nodes[0].sendrawtransaction(tx_hex), tx_id) assert(tx_id in self.nodes[0].getrawmempool()) + # Test that calling prioritisetransaction is sufficient to trigger + # getblocktemplate to (eventually) return a new block. + mock_time = int(time.time()) + self.nodes[0].setmocktime(mock_time) + template = self.nodes[0].getblocktemplate() + self.nodes[0].prioritisetransaction(tx_id, -int(self.relayfee*COIN)) + self.nodes[0].setmocktime(mock_time+10) + new_template = self.nodes[0].getblocktemplate() + + assert(template != new_template) + if __name__ == '__main__': PrioritiseTransactionTest().main()