Skip to content

Commit f6db48a

Browse files
committed
Merge #8838: Calculate size and weight of block correctly in CreateNewBlock()
5f274a1 log block size and weight correctly. (jnewbery)
2 parents cb2ed30 + 5f274a1 commit f6db48a

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/miner.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,6 @@ std::unique_ptr<CBlockTemplate> BlockAssembler::CreateNewBlock(const CScript& sc
169169
nLastBlockTx = nBlockTx;
170170
nLastBlockSize = nBlockSize;
171171
nLastBlockWeight = nBlockWeight;
172-
LogPrintf("CreateNewBlock(): total size %u txs: %u fees: %ld sigops %d\n", nBlockSize, nBlockTx, nFees, nBlockSigOpsCost);
173172

174173
// Create coinbase transaction.
175174
CMutableTransaction coinbaseTx;
@@ -183,6 +182,9 @@ std::unique_ptr<CBlockTemplate> BlockAssembler::CreateNewBlock(const CScript& sc
183182
pblocktemplate->vchCoinbaseCommitment = GenerateCoinbaseCommitment(*pblock, pindexPrev, chainparams.GetConsensus());
184183
pblocktemplate->vTxFees[0] = -nFees;
185184

185+
uint64_t nSerializeSize = GetSerializeSize(*pblock, SER_NETWORK, PROTOCOL_VERSION);
186+
LogPrintf("CreateNewBlock(): total size: %u block weight: %u txs: %u fees: %ld sigops %d\n", nSerializeSize, GetBlockWeight(*pblock), nBlockTx, nFees, nBlockSigOpsCost);
187+
186188
// Fill in header
187189
pblock->hashPrevBlock = pindexPrev->GetBlockHash();
188190
UpdateTime(pblock, chainparams.GetConsensus(), pindexPrev);

0 commit comments

Comments
 (0)