Skip to content

Commit

Permalink
Use a temp pindex to avoid a const_cast in ProcessNewBlockHeaders
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBlueMatt committed Jan 11, 2017
1 parent c1ae4fc commit 0df777d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/validation.cpp
Expand Up @@ -3035,11 +3035,13 @@ bool ProcessNewBlockHeaders(const std::vector<CBlockHeader>& headers, CValidatio
{
LOCK(cs_main);
for (const CBlockHeader& header : headers) {
// cast away the ppindex-returns-const CBlockIndex - we're just assigning it to a CBlockIndex*
// that we own and is updated non-const anyway
if (!AcceptBlockHeader(header, state, chainparams, const_cast<CBlockIndex**>(ppindex))) {
CBlockIndex *pindex = NULL; // Use a temp pindex instead of ppindex to avoid a const_cast
if (!AcceptBlockHeader(header, state, chainparams, &pindex)) {
return false;
}
if (ppindex) {
*ppindex = pindex;
}
}
}
NotifyHeaderTip();
Expand Down

0 comments on commit 0df777d

Please sign in to comment.