Browse Source

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
0.15
Pieter Wuille 7 years ago
parent
commit
bee3529971
No known key found for this signature in database
GPG Key ID: A636E97631F767E0
  1. 1
      src/txmempool.cpp
  2. 2
      src/txmempool.h
  3. 15
      test/functional/prioritise_transaction.py

1
src/txmempool.cpp

@ -865,6 +865,7 @@ void CTxMemPool::PrioritiseTransaction(const uint256& hash, const CAmount& nFeeD @@ -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));

2
src/txmempool.h

@ -397,7 +397,7 @@ class CTxMemPool @@ -397,7 +397,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.

15
test/functional/prioritise_transaction.py

@ -13,8 +13,8 @@ class PrioritiseTransactionTest(BitcoinTestFramework): @@ -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): @@ -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()

Loading…
Cancel
Save