Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13115793
D2862.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Subscribers
None
D2862.diff
View Options
diff --git a/src/miner.h b/src/miner.h
--- a/src/miner.h
+++ b/src/miner.h
@@ -26,11 +26,17 @@
struct CBlockTemplateEntry {
CTransactionRef tx;
- Amount fees;
- int64_t sigOpCount;
-
- CBlockTemplateEntry(CTransactionRef _tx, Amount _fees, int64_t _sigOpCount)
- : tx(_tx), fees(_fees), sigOpCount(_sigOpCount){};
+ //!< Total real fees paid by the transaction and cached to avoid parent
+ //!< lookup
+ Amount txFee;
+ //!< Cached total size of the transaction to avoid reserializing transaction
+ size_t txSize;
+ //!< Cached total number of SigOps
+ uint64_t txSigOps;
+
+ CBlockTemplateEntry(CTransactionRef _tx, Amount _fees, uint64_t _size,
+ int64_t _sigOps)
+ : tx(_tx), txFee(_fees), txSize(_size), txSigOps(_sigOps) {}
};
struct CBlockTemplate {
diff --git a/src/miner.cpp b/src/miner.cpp
--- a/src/miner.cpp
+++ b/src/miner.cpp
@@ -140,7 +140,7 @@
pblock = &pblocktemplate->block;
// Add dummy coinbase tx as first transaction. It is updated at the end.
- pblocktemplate->entries.emplace_back(CTransactionRef(), -SATOSHI, -1);
+ pblocktemplate->entries.emplace_back(CTransactionRef(), -SATOSHI, 0, -1);
LOCK2(cs_main, mempool->cs);
CBlockIndex *pindexPrev = chainActive.Tip();
@@ -204,7 +204,11 @@
}
pblocktemplate->entries[0].tx = MakeTransactionRef(coinbaseTx);
- pblocktemplate->entries[0].fees = -1 * nFees;
+ // Note: For the Coinbase, the template entry fields aside from the `tx` are
+ // not used anywhere at the time of writing. The mining rpc throws out the
+ // entire transaction in fact. The tx itself is only used during regtest
+ // mode.
+ pblocktemplate->entries[0].txFee = -1 * nFees;
uint64_t nSerializeSize =
GetSerializeSize(*pblock, SER_NETWORK, PROTOCOL_VERSION);
@@ -217,7 +221,7 @@
UpdateTime(pblock, *config, pindexPrev);
pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, *config);
pblock->nNonce = 0;
- pblocktemplate->entries[0].sigOpCount = GetSigOpCountWithoutP2SH(
+ pblocktemplate->entries[0].txSigOps = GetSigOpCountWithoutP2SH(
*pblocktemplate->entries[0].tx, STANDARD_CHECKDATASIG_VERIFY_FLAGS);
// Copy all the transactions into the block
@@ -355,6 +359,7 @@
void BlockAssembler::AddToBlock(CTxMemPool::txiter iter) {
pblocktemplate->entries.emplace_back(iter->GetSharedTx(), iter->GetFee(),
+ iter->GetTxSize(),
iter->GetSigOpCount());
nBlockSize += iter->GetTxSize();
++nBlockTx;
diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp
--- a/src/rpc/mining.cpp
+++ b/src/rpc/mining.cpp
@@ -628,10 +628,9 @@
entry.pushKV("data", EncodeHexTx(tx));
entry.pushKV("txid", txId.GetHex());
entry.pushKV("hash", tx.GetHash().GetHex());
- entry.pushKV("fee",
- pblocktemplate->entries[index_in_template].fees / SATOSHI);
- int64_t nTxSigOps =
- pblocktemplate->entries[index_in_template].sigOpCount;
+ entry.pushKV("fee", pblocktemplate->entries[index_in_template].txFee /
+ SATOSHI);
+ int64_t nTxSigOps = pblocktemplate->entries[index_in_template].txSigOps;
entry.pushKV("sigops", nTxSigOps);
transactions.push_back(entry);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Mar 1, 12:06 (3 h, 45 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5187773
Default Alt Text
D2862.diff (3 KB)
Attached To
D2862: [mining] Rename several CBlockTemplateEntry members for clarity
Event Timeline
Log In to Comment