Page MenuHomePhabricator

D3163.diff
No OneTemporary

D3163.diff

diff --git a/src/miner.h b/src/miner.h
--- a/src/miner.h
+++ b/src/miner.h
@@ -29,6 +29,10 @@
//!< Total real fees paid by the transaction and cached to avoid parent
//!< lookup
Amount txFee;
+ //!< Modified fees from mempool. Set by the prioritisetransaction rpc.
+ //!< We need this for ordering, but the above txFee for proper coinbase
+ //!< calculations.
+ Amount txModFee;
//!< Cached total size of the transaction to avoid reserializing transaction
size_t txSize;
//!< Cached total number of SigOps
@@ -45,11 +49,11 @@
//!< Estimated package sigops (This is guaranteed to be >= real sigops)
uint64_t packageSigOps;
- CBlockTemplateEntry(CTransactionRef _tx, Amount _fees, uint64_t _size,
- int64_t _sigOps)
- : tx(_tx), txFee(_fees), txSize(_size), txSigOps(_sigOps),
- packageOrder(0), packageFee(_fees), packageSize(_size),
- packageSigOps(_sigOps) {}
+ CBlockTemplateEntry(CTransactionRef _tx, Amount _fees, Amount _modFees,
+ uint64_t _size, int64_t _sigOps)
+ : tx(_tx), txFee(_fees), txModFee(_modFees), txSize(_size),
+ txSigOps(_sigOps), packageOrder(0), packageFee(_modFees),
+ packageSize(_size), packageSigOps(_sigOps) {}
/**
* Calculate the feerate for this transaction. Use the minimum of the
@@ -59,9 +63,9 @@
CFeeRate FeeRate() const {
// In order to avoid numerical errors, we reorder to use multiplication
// instead of vision.
- return int64_t(txSize) * packageFee < int64_t(packageSize) * txFee
+ return int64_t(txSize) * packageFee < int64_t(packageSize) * txModFee
? CFeeRate(packageFee, packageSize)
- : CFeeRate(txFee, txSize);
+ : CFeeRate(txModFee, txSize);
}
private:
diff --git a/src/miner.cpp b/src/miner.cpp
--- a/src/miner.cpp
+++ b/src/miner.cpp
@@ -140,7 +140,8 @@
pblock = &pblocktemplate->block;
// Add dummy coinbase tx as first transaction. It is updated at the end.
- pblocktemplate->entries.emplace_back(CTransactionRef(), -SATOSHI, 0, -1);
+ pblocktemplate->entries.emplace_back(CTransactionRef(), -SATOSHI, -SATOSHI,
+ 0, -1);
LOCK2(cs_main, mempool->cs);
CBlockIndex *pindexPrev = chainActive.Tip();
@@ -358,9 +359,9 @@
}
void BlockAssembler::AddToBlock(CTxMemPool::txiter iter) {
- pblocktemplate->entries.emplace_back(iter->GetSharedTx(), iter->GetFee(),
- iter->GetTxSize(),
- iter->GetSigOpCount());
+ pblocktemplate->entries.emplace_back(
+ iter->GetSharedTx(), iter->GetFee(), iter->GetModifiedFee(),
+ iter->GetTxSize(), iter->GetSigOpCount());
nBlockSize += iter->GetTxSize();
++nBlockTx;
nBlockSigOps += iter->GetSigOpCount();
diff --git a/src/test/miner_tests.cpp b/src/test/miner_tests.cpp
--- a/src/test/miner_tests.cpp
+++ b/src/test/miner_tests.cpp
@@ -780,21 +780,24 @@
BOOST_AUTO_TEST_CASE(TestCBlockTemplateEntry) {
const CTransaction tx;
CTransactionRef txRef = MakeTransactionRef(tx);
- CBlockTemplateEntry txEntry(txRef, 1 * SATOSHI, 200, 10);
+ CBlockTemplateEntry txEntry(txRef, 1 * SATOSHI, 2 * SATOSHI, 200, 10);
BOOST_CHECK_MESSAGE(txEntry.tx == txRef, "Transactions did not match");
BOOST_CHECK_EQUAL(txEntry.txFee, 1 * SATOSHI);
+ BOOST_CHECK_EQUAL(txEntry.txModFee, 2 * SATOSHI);
BOOST_CHECK_EQUAL(txEntry.txSize, 200);
BOOST_CHECK_EQUAL(txEntry.txSigOps, 10);
- BOOST_CHECK_EQUAL(txEntry.packageFee, 1 * SATOSHI);
+ BOOST_CHECK_EQUAL(txEntry.packageFee, 2 * SATOSHI);
BOOST_CHECK_EQUAL(txEntry.packageSize, 200);
BOOST_CHECK_EQUAL(txEntry.packageSigOps, 10);
- CBlockTemplateEntry txChildEntry(txRef, 10 * SATOSHI, 2000, 20);
+ CBlockTemplateEntry txChildEntry(txRef, 10 * SATOSHI, 11 * SATOSHI, 2000,
+ 20);
CBlockTemplateEntryTest::AccountForParent(txChildEntry, txEntry);
BOOST_CHECK_EQUAL(txChildEntry.txFee, 10 * SATOSHI);
+ BOOST_CHECK_EQUAL(txChildEntry.txModFee, 11 * SATOSHI);
BOOST_CHECK_EQUAL(txChildEntry.txSize, 2000);
BOOST_CHECK_EQUAL(txChildEntry.txSigOps, 20);
- BOOST_CHECK_EQUAL(txChildEntry.packageFee, 11 * SATOSHI);
+ BOOST_CHECK_EQUAL(txChildEntry.packageFee, 13 * SATOSHI);
BOOST_CHECK_EQUAL(txChildEntry.packageSize, 2200);
BOOST_CHECK_EQUAL(txChildEntry.packageSigOps, 30);
}

File Metadata

Mime Type
text/plain
Expires
Sat, Mar 1, 12:09 (3 h, 12 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5187789
Default Alt Text
D3163.diff (4 KB)

Event Timeline