diff --git a/src/chain.cpp b/src/chain.cpp --- a/src/chain.cpp +++ b/src/chain.cpp @@ -93,12 +93,12 @@ : InvertLowestOne(height); } -CBlockIndex *CBlockIndex::GetAncestor(int height) { +const CBlockIndex *CBlockIndex::GetAncestor(int height) const { if (height > nHeight || height < 0) { return nullptr; } - CBlockIndex *pindexWalk = this; + const CBlockIndex *pindexWalk = this; int heightWalk = nHeight; while (heightWalk > height) { int heightSkip = GetSkipHeight(heightWalk); @@ -119,8 +119,9 @@ return pindexWalk; } -const CBlockIndex *CBlockIndex::GetAncestor(int height) const { - return const_cast(this)->GetAncestor(height); +CBlockIndex *CBlockIndex::GetAncestor(int height) { + return const_cast( + const_cast(this)->GetAncestor(height)); } void CBlockIndex::BuildSkip() {