Created
February 20, 2015 03:50
-
-
Save dexX7/b8b47abaddf3619c3432 to your computer and use it in GitHub Desktop.
bool CheckBlockStorageOrder()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bool CheckBlockStorageOrder() | |
{ | |
AssertLockHeld(cs_main); | |
int nHeight = 0; | |
int nFilePrev = 0; | |
unsigned int nPosPrev = 0; | |
int nHeightChain = chainActive.Height(); | |
CBlockIndex* pindex = chainActive.Genesis(); | |
while (pindex) { | |
int nFile = pindex->GetBlockPos().nFile; | |
unsigned int nPos = pindex->GetBlockPos().nPos; | |
nHeight = pindex->nHeight; | |
if (nFile > nFilePrev) { | |
// moving onto a new blk?????.dat | |
nPosPrev = 0; | |
} | |
if (nPos <= nPosPrev) { | |
// found a blocks stored out of order | |
return false; | |
} | |
nFilePrev = nFile; | |
nPosPrev = nPos; | |
pindex = chainActive.Next(pindex); | |
} | |
if (nHeight < nHeightChain) { | |
// blocks appear to be missing and have no successor | |
return false; | |
} | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment