Skip to content
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

Dev #309

Merged
merged 12 commits into from
Mar 18, 2017
Merged

Dev #309

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1464,7 +1464,13 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
uiInterface.InitMessage(_("Activating best chain..."));
// scan for better chains in the block chain database, that are not yet connected in the active best chain
CValidationState state;
if (!ActivateBestChain(state))
extern int32_t KOMODO_REWIND;
if ( KOMODO_REWIND < 0 )
{
KOMODO_REWIND = 0;
fprintf(stderr,"bypass ActivateBestChain\n");
}
else if ( !ActivateBestChain(state))
strErrors << "Failed to connect best block";

std::vector<boost::filesystem::path> vImportFiles;
Expand Down
16 changes: 9 additions & 7 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2769,18 +2769,21 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo
if (!DisconnectTip(state))
return false;
}
if ( KOMODO_REWIND != 0 && chainActive.Tip()->nHeight >= KOMODO_REWIND )
if ( KOMODO_REWIND != 0 && chainActive.Tip()->nHeight >= KOMODO_REWIND-1 )
{
//static int32_t didinit;
//if ( didinit++ == 0 )
if ( chainActive.Tip()->nHeight == KOMODO_REWIND+1 )
static int32_t didinit;
if ( chainActive.Tip()->nHeight == KOMODO_REWIND )
{
pindexOldTip = pindexMostWork = chainActive.Tip();
fprintf(stderr,"reached rewind.%d, best to do: ./komodo-cli stop\n",KOMODO_REWIND);
pindexFork = chainActive.FindFork(pindexMostWork);
sleep(3);
return(false);
didinit++;
return(true);
}
if ( didinit == 0 )
{
while (chainActive.Tip()->nHeight > KOMODO_REWIND )
while (chainActive.Tip()->nHeight >= KOMODO_REWIND )
{
fprintf(stderr,"rewind ht.%d\n",chainActive.Tip()->nHeight);
if ( !DisconnectTip(state) )
Expand Down Expand Up @@ -2868,7 +2871,6 @@ bool ActivateBestChain(CValidationState &state, CBlock *pblock) {

if (!ActivateBestChainStep(state, pindexMostWork, pblock && pblock->GetHash() == pindexMostWork->GetBlockHash() ? pblock : NULL))
return false;

pindexNewTip = chainActive.Tip();
fInitialDownload = IsInitialBlockDownload();
}
Expand Down