Skip to content

Commit 0df777d

Browse files
committed
Use a temp pindex to avoid a const_cast in ProcessNewBlockHeaders
1 parent c1ae4fc commit 0df777d

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/validation.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3035,11 +3035,13 @@ bool ProcessNewBlockHeaders(const std::vector<CBlockHeader>& headers, CValidatio
30353035
{
30363036
LOCK(cs_main);
30373037
for (const CBlockHeader& header : headers) {
3038-
// cast away the ppindex-returns-const CBlockIndex - we're just assigning it to a CBlockIndex*
3039-
// that we own and is updated non-const anyway
3040-
if (!AcceptBlockHeader(header, state, chainparams, const_cast<CBlockIndex**>(ppindex))) {
3038+
CBlockIndex *pindex = NULL; // Use a temp pindex instead of ppindex to avoid a const_cast
3039+
if (!AcceptBlockHeader(header, state, chainparams, &pindex)) {
30413040
return false;
30423041
}
3042+
if (ppindex) {
3043+
*ppindex = pindex;
3044+
}
30433045
}
30443046
}
30453047
NotifyHeaderTip();

0 commit comments

Comments
 (0)