forked from dashpay/dash
-
Notifications
You must be signed in to change notification settings - Fork 714
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Main] Automate database corruption fix caused by out of sync txdb. #405
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
5654732
Automate database corruption fix caused by out of sync txdb.
presstab 3eabaa2
Remove unused code and add null check.
presstab 43af66b
Add message popup when db corrupt. Make ReindexAccumulators() use ref…
presstab 15c355b
Ask for sporks from 1st peer. Consider Verifying Blocks as IDB.
presstab 8469261
Deprecate spork_11.
presstab File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1371,59 +1371,13 @@ bool AppInit2(boost::thread_group& threadGroup) | |
} | ||
|
||
// PIVX: recalculate Accumulator Checkpoints that failed to database properly | ||
if (!listAccCheckpointsNoDB.empty() && chainActive.Tip()->GetBlockHeader().nVersion >= Params().Zerocoin_HeaderVersion()) { | ||
if (!listAccCheckpointsNoDB.empty()) { | ||
uiInterface.InitMessage(_("Calculating missing accumulators...")); | ||
LogPrintf("%s : finding missing checkpoints\n", __func__); | ||
|
||
//search the chain to see when zerocoin started | ||
int nZerocoinStart = 0; | ||
CBlockIndex* pindex = chainActive.Tip(); | ||
while (pindex->pprev) { | ||
if (pindex->GetBlockHeader().nVersion >= Params().Zerocoin_HeaderVersion()) | ||
nZerocoinStart = pindex->nHeight; | ||
else if (nZerocoinStart) | ||
break; | ||
|
||
pindex = pindex->pprev; | ||
} | ||
|
||
// find each checkpoint that is missing | ||
pindex = chainActive[nZerocoinStart]; | ||
while (!listAccCheckpointsNoDB.empty()) { | ||
if (ShutdownRequested()) | ||
break; | ||
|
||
// find checkpoints by iterating through the blockchain beginning with the first zerocoin block | ||
if (pindex->nAccumulatorCheckpoint != pindex->pprev->nAccumulatorCheckpoint) { | ||
|
||
double dPercent = (pindex->nHeight - nZerocoinStart) / (double)(chainActive.Height() - nZerocoinStart); | ||
uiInterface.ShowProgress(_("Calculating missing accumulators..."), (int)(dPercent * 100)); | ||
if(find(listAccCheckpointsNoDB.begin(), listAccCheckpointsNoDB.end(), pindex->nAccumulatorCheckpoint) != listAccCheckpointsNoDB.end()) { | ||
uint256 nCheckpointCalculated = 0; | ||
if (!CalculateAccumulatorCheckpoint(pindex->nHeight, nCheckpointCalculated)) { | ||
// GetCheckpoint could have terminated due to a shutdown request. Check this here. | ||
if (ShutdownRequested()) | ||
break; | ||
return InitError(_("Failed to calculate accumulator checkpoint")); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what would the reason be for failure here? |
||
} | ||
|
||
//check that the calculated checkpoint is what is in the index. | ||
if(nCheckpointCalculated != pindex->nAccumulatorCheckpoint) { | ||
LogPrintf("%s : height=%d calculated_checkpoint=%s actual=%s\n", __func__, pindex->nHeight, nCheckpointCalculated.GetHex(), pindex->nAccumulatorCheckpoint.GetHex()); | ||
return InitError(_("Calculated accumulator checkpoint is not what is recorded by block index")); | ||
} | ||
|
||
auto it = find(listAccCheckpointsNoDB.begin(), listAccCheckpointsNoDB.end(), pindex->nAccumulatorCheckpoint); | ||
listAccCheckpointsNoDB.erase(it); | ||
} | ||
} | ||
|
||
// if we have iterated to the end of the blockchain, then checkpoints should be in sync | ||
if (pindex->nHeight + 1 <= chainActive.Height()) | ||
pindex = chainActive[pindex->nHeight + 1]; | ||
else | ||
break; | ||
} | ||
string strError; | ||
if (!ReindexAccumulators(listAccCheckpointsNoDB, strError)) | ||
return InitError(strError); | ||
} | ||
|
||
uiInterface.InitMessage(_("Verifying blocks...")); | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would have helped to know you were looping backwards here. (comment). Also would a "==" have worked?