Skip to content

Commit bee3529

Browse files
committed
Merge #10196: Bugfix: PrioritiseTransaction updates the mempool tx counter
6c2e25c [qa] Test prioritise_transaction / getblocktemplate interaction (Suhas Daftuar) acc2e4b Bugfix: PrioritiseTransaction updates the mempool tx counter (Suhas Daftuar) Tree-SHA512: dcf834df52d84d5eb86acb847c3f28d3cffd1f78f3092b8ff8913c2c400675a071c48a19cd852fdbaac1582aa1dba23433e0e16055831ef2a5e76dde91199941
2 parents 318ea50 + 6c2e25c commit bee3529

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

src/txmempool.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -865,6 +865,7 @@ void CTxMemPool::PrioritiseTransaction(const uint256& hash, const CAmount& nFeeD
865865
BOOST_FOREACH(txiter descendantIt, setDescendants) {
866866
mapTx.modify(descendantIt, update_ancestor_state(0, nFeeDelta, 0, 0));
867867
}
868+
++nTransactionsUpdated;
868869
}
869870
}
870871
LogPrintf("PrioritiseTransaction: %s feerate += %s\n", hash.ToString(), FormatMoney(nFeeDelta));

src/txmempool.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ class CTxMemPool
397397
{
398398
private:
399399
uint32_t nCheckFrequency; //!< Value n means that n times in 2^32 we check.
400-
unsigned int nTransactionsUpdated;
400+
unsigned int nTransactionsUpdated; //!< Used by getblocktemplate to trigger CreateNewBlock() invocation
401401
CBlockPolicyEstimator* minerPolicyEstimator;
402402

403403
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.

test/functional/prioritise_transaction.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ class PrioritiseTransactionTest(BitcoinTestFramework):
1313
def __init__(self):
1414
super().__init__()
1515
self.setup_clean_chain = True
16-
self.num_nodes = 1
17-
self.extra_args = [["-printpriority=1"]]
16+
self.num_nodes = 2
17+
self.extra_args = [["-printpriority=1"], ["-printpriority=1"]]
1818

1919
def run_test(self):
2020
self.txouts = gen_return_txouts()
@@ -115,5 +115,16 @@ def run_test(self):
115115
assert_equal(self.nodes[0].sendrawtransaction(tx_hex), tx_id)
116116
assert(tx_id in self.nodes[0].getrawmempool())
117117

118+
# Test that calling prioritisetransaction is sufficient to trigger
119+
# getblocktemplate to (eventually) return a new block.
120+
mock_time = int(time.time())
121+
self.nodes[0].setmocktime(mock_time)
122+
template = self.nodes[0].getblocktemplate()
123+
self.nodes[0].prioritisetransaction(tx_id, -int(self.relayfee*COIN))
124+
self.nodes[0].setmocktime(mock_time+10)
125+
new_template = self.nodes[0].getblocktemplate()
126+
127+
assert(template != new_template)
128+
118129
if __name__ == '__main__':
119130
PrioritiseTransactionTest().main()

0 commit comments

Comments
 (0)