diff options
| author | Matt Corallo <[email protected]> | 2017-01-11 14:47:52 -0800 |
|---|---|---|
| committer | Matt Corallo <[email protected]> | 2017-01-11 14:47:52 -0800 |
| commit | 0df777db6d62a4fc3353edecdcc0094dc1abbd18 (patch) | |
| tree | 4d684965107e3322c6a83b8da063d917b0f3fdcc /src/validation.cpp | |
| parent | Avoid holding cs_most_recent_block while calling ReadBlockFromDisk (diff) | |
| download | discoin-0df777db6d62a4fc3353edecdcc0094dc1abbd18.tar.xz discoin-0df777db6d62a4fc3353edecdcc0094dc1abbd18.zip | |
Use a temp pindex to avoid a const_cast in ProcessNewBlockHeaders
Diffstat (limited to 'src/validation.cpp')
| -rw-r--r-- | src/validation.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/validation.cpp b/src/validation.cpp index 20d75d957..5f0cf10ce 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -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(); |