Skip to content

Commit cbe7efe

Browse files
committed
Merge #15389: Remove unnecessary const_cast
5039e4b Remove unnecessary const_cast (Julian Fleischer) Pull request description: The const_cast ```C++ CBlock &block = const_cast<CBlock&>(chainparams.GenesisBlock()); ``` is not necessary as all the functions invoked form this block receive a `const CBlock&` anyway. Simply add the `const` to `block`: ```C++ const CBlock& block = chainparams.GenesisBlock(); ``` Casting away `const`, especially from something as precious as the genesis block, feels really weird to me as a reader of bitcoin-core source code. Tree-SHA512: 0290b2cabb216a60655ded153ed1f213c051fb216cec6f3f810f8b760e276f8def86eb696c492e89631682531e215f56d7897b59685d3aa787bcd80cc4f86c90
2 parents 0d1160e + 5039e4b commit cbe7efe

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/validation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4347,7 +4347,7 @@ bool CChainState::LoadGenesisBlock(const CChainParams& chainparams)
43474347
return true;
43484348

43494349
try {
4350-
CBlock &block = const_cast<CBlock&>(chainparams.GenesisBlock());
4350+
const CBlock& block = chainparams.GenesisBlock();
43514351
CDiskBlockPos blockPos = SaveBlockToDisk(block, 0, chainparams, nullptr);
43524352
if (blockPos.IsNull())
43534353
return error("%s: writing genesis block to disk failed", __func__);

0 commit comments

Comments
 (0)