From 8f98af3629051d36fde0a82bb2bbf64da6eb2dee Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 18 Mar 2017 09:53:23 +0200 Subject: [PATCH 01/12] Test --- src/main.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 825088d76..4dd841747 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2867,7 +2867,11 @@ bool ActivateBestChain(CValidationState &state, CBlock *pblock) { return true; if (!ActivateBestChainStep(state, pindexMostWork, pblock && pblock->GetHash() == pindexMostWork->GetBlockHash() ? pblock : NULL)) - return false; + { + if ( KOMODO_REWIND == 0 ) + return false; + else return true; + } pindexNewTip = chainActive.Tip(); fInitialDownload = IsInitialBlockDownload(); From e513dc2a5fcede05379b6ac38f41f8612b24be9d Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 18 Mar 2017 09:59:29 +0200 Subject: [PATCH 02/12] Test --- src/main.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 4dd841747..b1177908c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2773,11 +2773,11 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo { //static int32_t didinit; //if ( didinit++ == 0 ) - if ( chainActive.Tip()->nHeight == KOMODO_REWIND+1 ) + if ( chainActive.Tip()->nHeight == KOMODO_REWIND ) { + pindexMostWork = chainActive.Tip(); fprintf(stderr,"reached rewind.%d, best to do: ./komodo-cli stop\n",KOMODO_REWIND); - sleep(3); - return(false); + return(true); } { while (chainActive.Tip()->nHeight > KOMODO_REWIND ) @@ -2867,11 +2867,7 @@ bool ActivateBestChain(CValidationState &state, CBlock *pblock) { return true; if (!ActivateBestChainStep(state, pindexMostWork, pblock && pblock->GetHash() == pindexMostWork->GetBlockHash() ? pblock : NULL)) - { - if ( KOMODO_REWIND == 0 ) - return false; - else return true; - } + return false; pindexNewTip = chainActive.Tip(); fInitialDownload = IsInitialBlockDownload(); From 0364009ed95b2bf73d439388362bf0f3a1b02036 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 18 Mar 2017 10:01:53 +0200 Subject: [PATCH 03/12] Test --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index b1177908c..65a641cec 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2777,7 +2777,7 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo { pindexMostWork = chainActive.Tip(); fprintf(stderr,"reached rewind.%d, best to do: ./komodo-cli stop\n",KOMODO_REWIND); - return(true); + return(false); } { while (chainActive.Tip()->nHeight > KOMODO_REWIND ) From 2e245d5b305bec08e2005fb94114f39eba85b131 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 18 Mar 2017 10:06:35 +0200 Subject: [PATCH 04/12] Test --- src/main.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 65a641cec..174893a1a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2775,9 +2775,11 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo //if ( didinit++ == 0 ) if ( chainActive.Tip()->nHeight == KOMODO_REWIND ) { - pindexMostWork = chainActive.Tip(); + pindexOldTip = pindexMostWork = chainActive.Tip(); fprintf(stderr,"reached rewind.%d, best to do: ./komodo-cli stop\n",KOMODO_REWIND); - return(false); + pindexFork = chainActive.FindFork(pindexMostWork); + sleep(3); + //return(false); } { while (chainActive.Tip()->nHeight > KOMODO_REWIND ) From 503bab202930d2d2231bc93aaf4e89396b72775f Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 18 Mar 2017 10:11:15 +0200 Subject: [PATCH 05/12] Test --- src/main.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main.cpp b/src/main.cpp index 174893a1a..84a7ce795 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2778,6 +2778,7 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo pindexOldTip = pindexMostWork = chainActive.Tip(); fprintf(stderr,"reached rewind.%d, best to do: ./komodo-cli stop\n",KOMODO_REWIND); pindexFork = chainActive.FindFork(pindexMostWork); + KOMODO_REWIND = 0; sleep(3); //return(false); } From 5228ba8d86c0bd614f7630cd32baee6cf9a65cff Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 18 Mar 2017 10:16:29 +0200 Subject: [PATCH 06/12] Test --- src/main.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 84a7ce795..1921df0ea 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2771,17 +2771,17 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo } if ( KOMODO_REWIND != 0 && chainActive.Tip()->nHeight >= KOMODO_REWIND ) { - //static int32_t didinit; - //if ( didinit++ == 0 ) + 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); - KOMODO_REWIND = 0; sleep(3); - //return(false); + didinit++; + return(false); } + if ( didinit == 0 ) { while (chainActive.Tip()->nHeight > KOMODO_REWIND ) { @@ -2870,8 +2870,11 @@ bool ActivateBestChain(CValidationState &state, CBlock *pblock) { return true; if (!ActivateBestChainStep(state, pindexMostWork, pblock && pblock->GetHash() == pindexMostWork->GetBlockHash() ? pblock : NULL)) - return false; - + { + if ( KOMODO_REWIND == 0 ) + return false; + fprintf(stderr,"ActivateBestChainStep rewind case\n"); + } pindexNewTip = chainActive.Tip(); fInitialDownload = IsInitialBlockDownload(); } From f40ac311977aebca5cf31aa2a4e8cbcd02331f13 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 18 Mar 2017 10:23:43 +0200 Subject: [PATCH 07/12] Test --- src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 1921df0ea..d435d7afc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2769,7 +2769,7 @@ 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 ( chainActive.Tip()->nHeight == KOMODO_REWIND ) @@ -2783,7 +2783,7 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo } 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) ) From 120e6f4c4f23ddceec8d6ea794e59922a253b1eb Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 18 Mar 2017 10:28:19 +0200 Subject: [PATCH 08/12] Test --- src/main.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main.cpp b/src/main.cpp index d435d7afc..bd530461a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2874,6 +2874,7 @@ bool ActivateBestChain(CValidationState &state, CBlock *pblock) { if ( KOMODO_REWIND == 0 ) return false; fprintf(stderr,"ActivateBestChainStep rewind case\n"); + return true; } pindexNewTip = chainActive.Tip(); fInitialDownload = IsInitialBlockDownload(); From 9083591a3723f63ebf332789fbee883d9478ebc5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 18 Mar 2017 10:34:00 +0200 Subject: [PATCH 09/12] Test --- src/init.cpp | 2 +- src/main.cpp | 7 +------ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index 2336a9101..e2df87ed1 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1464,7 +1464,7 @@ 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)) + if (KOMODO_REWIND == 0 && !ActivateBestChain(state)) strErrors << "Failed to connect best block"; std::vector vImportFiles; diff --git a/src/main.cpp b/src/main.cpp index bd530461a..e3ea9cab7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2870,12 +2870,7 @@ bool ActivateBestChain(CValidationState &state, CBlock *pblock) { return true; if (!ActivateBestChainStep(state, pindexMostWork, pblock && pblock->GetHash() == pindexMostWork->GetBlockHash() ? pblock : NULL)) - { - if ( KOMODO_REWIND == 0 ) - return false; - fprintf(stderr,"ActivateBestChainStep rewind case\n"); - return true; - } + return false; pindexNewTip = chainActive.Tip(); fInitialDownload = IsInitialBlockDownload(); } From d27148cf0cb242534cb2b4e54365755ffd87583a Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 18 Mar 2017 10:38:10 +0200 Subject: [PATCH 10/12] Test --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index e3ea9cab7..06ef18e33 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2779,7 +2779,7 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo pindexFork = chainActive.FindFork(pindexMostWork); sleep(3); didinit++; - return(false); + return(true); } if ( didinit == 0 ) { From 3938336c6c420c11eeaf72cba78022f616ba725c Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 18 Mar 2017 10:45:40 +0200 Subject: [PATCH 11/12] Test --- src/init.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/init.cpp b/src/init.cpp index e2df87ed1..d586108a4 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1464,7 +1464,12 @@ 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 (KOMODO_REWIND == 0 && !ActivateBestChain(state)) + if ( KOMODO_REWIND < 0 ) + { + KOMODO_REWIND = 0; + fprintf(stderr,"bypass ActivateBestChain\n"); + } + else if ( !ActivateBestChain(state)) strErrors << "Failed to connect best block"; std::vector vImportFiles; From 373e276894c14bb180cbc813652f17344ddd3dfc Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 18 Mar 2017 10:46:45 +0200 Subject: [PATCH 12/12] Test --- src/init.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/init.cpp b/src/init.cpp index d586108a4..95bff62d5 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1464,6 +1464,7 @@ 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; + extern int32_t KOMODO_REWIND; if ( KOMODO_REWIND < 0 ) { KOMODO_REWIND = 0;