From 8f98af3629051d36fde0a82bb2bbf64da6eb2dee Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 18 Mar 2017 09:53:23 +0200 Subject: [PATCH 01/21] 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/21] 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/21] 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/21] 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/21] 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/21] 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/21] 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/21] 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/21] 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/21] 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/21] 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/21] 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; From 6856606faf3314ac24952cfe442a750e9ef3d94b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 18 Mar 2017 11:42:32 +0200 Subject: [PATCH 13/21] Test --- src/komodo_gateway.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 5cdf8548a..d2d41d685 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1127,7 +1127,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 void komodo_passport_iteration() { - static long lastpos[34]; static char userpass[33][1024]; int32_t maxseconds = 17; + static long lastpos[34]; static char userpass[33][1024]; int32_t maxseconds = 1; FILE *fp; int32_t baseid,n,ht,isrealtime,expired,refid,blocks,longest; struct komodo_state *sp,*refsp; char *retstr,fname[512],*base,symbol[16],dest[16]; uint32_t buf[3],starttime; cJSON *infoobj,*result; uint64_t RTmask = 0; //printf("PASSPORT.(%s)\n",ASSETCHAINS_SYMBOL); expired = 0; @@ -1176,7 +1176,7 @@ void komodo_passport_iteration() if ( 0 && lastpos[baseid] == 0 && strcmp(symbol,"KMD") == 0 ) printf("passport refid.%d %s fname.(%s) base.%s\n",refid,symbol,fname,base); fseek(fp,lastpos[baseid],SEEK_SET); - while ( komodo_parsestatefile(sp,fp,symbol,dest) >= 0 && n < 10000 ) + while ( komodo_parsestatefile(sp,fp,symbol,dest) >= 0 && n < 1000 ) { if ( n == 999 ) { From f4b73908f18d312f177fce790208c08f71bae0ad Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 18 Mar 2017 11:51:12 +0200 Subject: [PATCH 14/21] Test --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 06ef18e33..e308a2b08 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2781,7 +2781,7 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo didinit++; return(true); } - if ( didinit == 0 ) + //if ( didinit == 0 ) { while (chainActive.Tip()->nHeight >= KOMODO_REWIND ) { From 297a497832ad1c412ac64d502364341a69662acb Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 18 Mar 2017 11:57:54 +0200 Subject: [PATCH 15/21] Test --- src/main.cpp | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index e308a2b08..91e1ed721 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2769,32 +2769,28 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo if (!DisconnectTip(state)) return false; } - if ( KOMODO_REWIND != 0 && chainActive.Tip()->nHeight >= KOMODO_REWIND-1 ) + if ( KOMODO_REWIND != 0 && chainActive.Tip()->nHeight >= KOMODO_REWIND ) { - static int32_t didinit; + fprintf(stderr,"rewind ht.%d\n",chainActive.Tip()->nHeight); + while ( chainActive.Tip()->nHeight > KOMODO_REWIND ) + { + if ( !DisconnectTip(state) ) + { + //InvalidateBlock(state,chainActive.Tip()); + return false; + } + } + fprintf(stderr,"end rewind ht.%d\n",chainActive.Tip()->nHeight); 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); - didinit++; return(true); } - //if ( didinit == 0 ) - { - while (chainActive.Tip()->nHeight >= KOMODO_REWIND ) - { - fprintf(stderr,"rewind ht.%d\n",chainActive.Tip()->nHeight); - if ( !DisconnectTip(state) ) - { - InvalidateBlock(state,chainActive.Tip()); - return false; - } - } - pindexOldTip = chainActive.Tip(); - pindexFork = chainActive.FindFork(pindexMostWork); - } + pindexOldTip = chainActive.Tip(); + pindexFork = chainActive.FindFork(pindexMostWork); } // Build list of new blocks to connect. std::vector vpindexToConnect; From 6a877e46d5ca4fb32ed07bd0b38e54f7137c58dc Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 18 Mar 2017 12:23:35 +0200 Subject: [PATCH 16/21] Test --- src/init.cpp | 20 +++++--------------- src/komodo_globals.h | 2 +- src/komodo_utils.h | 4 ++-- src/main.cpp | 6 ++---- src/pow.cpp | 7 ++++--- src/wallet/wallet.cpp | 4 ++-- 6 files changed, 16 insertions(+), 27 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index 95bff62d5..59dcc27b9 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1244,14 +1244,10 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) LogPrintf("Prune: pruned datadir may not have more than %d blocks; -checkblocks=%d may fail\n", MIN_BLOCKS_TO_KEEP, GetArg("-checkblocks", 288)); } - extern int32_t KOMODO_REWIND; - if ( KOMODO_REWIND == 0 ) - { - if (!CVerifyDB().VerifyDB(pcoinsdbview, GetArg("-checklevel", 3), - GetArg("-checkblocks", 288))) { - strLoadError = _("Corrupted block database detected"); - break; - } + if (!CVerifyDB().VerifyDB(pcoinsdbview, GetArg("-checklevel", 3), + GetArg("-checkblocks", 288))) { + strLoadError = _("Corrupted block database detected"); + break; } } catch (const std::exception& e) { if (fDebug) LogPrintf("%s\n", e.what()); @@ -1464,13 +1460,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; - fprintf(stderr,"bypass ActivateBestChain\n"); - } - else if ( !ActivateBestChain(state)) + if ( !ActivateBestChain(state)) strErrors << "Failed to connect best block"; std::vector vImportFiles; diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 9af4d0b36..9b93ff57e 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -40,7 +40,7 @@ struct komodo_state KOMODO_STATES[34]; #define _COINBASE_MATURITY 100 int COINBASE_MATURITY = _COINBASE_MATURITY;//100; -int32_t IS_KOMODO_NOTARY,KOMODO_REWIND,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET; +int32_t IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET; int32_t KOMODO_LASTMINED,prevKOMODO_LASTMINED; std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES; uint8_t NOTARY_PUBKEY33[33]; diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 7c99aa4b2..1c32bb068 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1463,10 +1463,10 @@ void komodo_args() KOMODO_PAX = 1; } else KOMODO_PAX = GetArg("-pax",0); name = GetArg("-ac_name",""); - if ( (KOMODO_REWIND= GetArg("-rewind",0)) != 0 ) + /*if ( (KOMODO_REWIND= GetArg("-rewind",0)) != 0 ) { printf("KOMODO_REWIND %d\n",KOMODO_REWIND); - } + }*/ if ( name.c_str()[0] != 0 ) { ASSETCHAINS_SUPPLY = GetArg("-ac_supply",10); diff --git a/src/main.cpp b/src/main.cpp index 91e1ed721..a45caae1a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2758,7 +2758,6 @@ static void PruneBlockIndexCandidates() { * pblock is either NULL or a pointer to a CBlock corresponding to pindexMostWork. */ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMostWork, CBlock *pblock) { - extern int32_t KOMODO_REWIND; AssertLockHeld(cs_main); bool fInvalidFound = false; const CBlockIndex *pindexOldTip = chainActive.Tip(); @@ -2769,6 +2768,7 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo if (!DisconnectTip(state)) return false; } + /*fprintf(stderr,"chaintip %d vs rewind.%d\n",(int32_t)chainActive.Tip()->nHeight,KOMODO_REWIND); if ( KOMODO_REWIND != 0 && chainActive.Tip()->nHeight >= KOMODO_REWIND ) { fprintf(stderr,"rewind ht.%d\n",chainActive.Tip()->nHeight); @@ -2783,15 +2783,13 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo fprintf(stderr,"end rewind ht.%d\n",chainActive.Tip()->nHeight); 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(true); } pindexOldTip = chainActive.Tip(); pindexFork = chainActive.FindFork(pindexMostWork); - } + }*/ // Build list of new blocks to connect. std::vector vpindexToConnect; bool fContinue = true; diff --git a/src/pow.cpp b/src/pow.cpp index cfdaea121..655a9dfad 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -119,7 +119,7 @@ extern std::string NOTARY_PUBKEY; bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned int nBits, const Consensus::Params& params) { - extern int32_t KOMODO_REWIND; + //extern int32_t KOMODO_REWIND; bool fNegative,fOverflow; int32_t i,nonzpkeys=0,nonz=0,special=0,special2=0,notaryid=-1,duplicate,flag = 0, mids[66]; arith_uint256 bnTarget; CBlockIndex *pindex; uint8_t pubkeys[66][33]; @@ -155,7 +155,8 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in // Check proof of work matches claimed amount if ( UintToArith256(hash) > bnTarget ) { - if ( (height < 235300 || height >= 236000) && KOMODO_LOADINGBLOCKS == 0 && height > 188000 && KOMODO_REWIND == 0 )//186269, 182507&& komodo_chainactive(height) != 0 && nonzpkeys > 0 + if ( (height < 235300 || height >= 236000) && KOMODO_LOADINGBLOCKS == 0 && height > 188000 ) + //&& KOMODO_REWIND == 0 )//186269, 182507&& komodo_chainactive(height) != 0 && nonzpkeys > 0 { int32_t i; for (i=31; i>=0; i--) @@ -163,7 +164,7 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in printf(" hash vs "); for (i=31; i>=0; i--) printf("%02x",((uint8_t *)&bnTarget)[i]); - printf(" ht.%d REWIND.%d special.%d notaryid.%d ht.%d mod.%d error\n",height,KOMODO_REWIND,special,notaryid,height,(height % 35)); + printf(" ht.%d special.%d notaryid.%d ht.%d mod.%d error\n",height,special,notaryid,height,(height % 35)); for (i=0; i<33; i++) printf("%02x",pubkey33[i]); printf(" <- pubkey\n"); diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 091fb5e22..ac7f1f9f5 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -757,7 +757,7 @@ void CWallet::IncrementNoteWitnesses(const CBlockIndex* pindex, void CWallet::DecrementNoteWitnesses(const CBlockIndex* pindex) { - extern int32_t KOMODO_REWIND; + //extern int32_t KOMODO_REWIND; { LOCK(cs_wallet); for (std::pair& wtxItem : mapWallet) { @@ -806,7 +806,7 @@ void CWallet::DecrementNoteWitnesses(const CBlockIndex* pindex) extern char ASSETCHAINS_SYMBOL[16]; fprintf(stderr,"%s nWitnessCacheSize.%d\n",ASSETCHAINS_SYMBOL,(int32_t)nWitnessCacheSize); } - if ( KOMODO_REWIND == 0 ) + //if ( KOMODO_REWIND == 0 ) assert(nWitnessCacheSize > 0); //if (fFileBacked) { // CWalletDB walletdb(strWalletFile); From 48e3b128542b92aee031d978448da573c1c38627 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 18 Mar 2017 12:50:25 +0200 Subject: [PATCH 17/21] Test --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index a45caae1a..8cd234095 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1551,7 +1551,7 @@ bool IsInitialBlockDownload() state = (chainActive.Height() < ptr->nHeight - 24*6) || ptr->GetBlockTime() < (GetTime() - chainParams.MaxTipAge()); else state = (chainActive.Height() < ptr->nHeight - 100); - //fprintf(stderr,"state.%d ht.%d vs %d, t.%u %u\n",state,(int32_t)chainActive.Height(),(uint32_t)ptr->nHeight,(int32_t)ptr->GetBlockTime(),(uint32_t)(GetTime() - chainParams.MaxTipAge())); + fprintf(stderr,"state.%d ht.%d vs %d, t.%u %u\n",state,(int32_t)chainActive.Height(),(uint32_t)ptr->nHeight,(int32_t)ptr->GetBlockTime(),(uint32_t)(GetTime() - chainParams.MaxTipAge())); if (!state) { lockIBDState = true; From 3d3374839c7f481d6d1d4f4421afe3231e5fdae4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 18 Mar 2017 12:54:07 +0200 Subject: [PATCH 18/21] Test --- src/main.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 8cd234095..c1d85af59 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1548,10 +1548,10 @@ bool IsInitialBlockDownload() else if ( pindexBestHeader != 0 && pindexBestHeader->nHeight > ptr->nHeight ) ptr = pindexBestHeader; if ( ASSETCHAINS_SYMBOL[0] == 0 ) - state = (chainActive.Height() < ptr->nHeight - 24*6) || - ptr->GetBlockTime() < (GetTime() - chainParams.MaxTipAge()); + state = chainActive.Height() < 241777 && ((chainActive.Height() < ptr->nHeight - 24*6) || + ptr->GetBlockTime() < (GetTime() - chainParams.MaxTipAge())); else state = (chainActive.Height() < ptr->nHeight - 100); - fprintf(stderr,"state.%d ht.%d vs %d, t.%u %u\n",state,(int32_t)chainActive.Height(),(uint32_t)ptr->nHeight,(int32_t)ptr->GetBlockTime(),(uint32_t)(GetTime() - chainParams.MaxTipAge())); + //fprintf(stderr,"state.%d ht.%d vs %d, t.%u %u\n",state,(int32_t)chainActive.Height(),(uint32_t)ptr->nHeight,(int32_t)ptr->GetBlockTime(),(uint32_t)(GetTime() - chainParams.MaxTipAge())); if (!state) { lockIBDState = true; From e9134f7f9ef1686197eeec5b45ab5a1d4637cc13 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 18 Mar 2017 13:16:33 +0200 Subject: [PATCH 19/21] Test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index d2d41d685..556326102 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1207,7 +1207,7 @@ void komodo_passport_iteration() isrealtime = 1; RTmask |= (1LL << baseid); memcpy(refsp->RTbufs[baseid+1],buf,sizeof(refsp->RTbufs[baseid+1])); - } else if ( (time(NULL)-buf[2]) > 1800 ) + } else if ( (time(NULL)-buf[2]) > 1800 && ASSETCHAINS_SYMBOL[0] != 0 ) fprintf(stderr,"[%s]: %s not RT %u %u %d\n",ASSETCHAINS_SYMBOL,base,buf[0],buf[1],(int32_t)(time(NULL)-buf[2])); } //else fprintf(stderr,"%s size error RT\n",base); fclose(fp); From 4608ac92db5584148e528806432b5dc452995bc6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 18 Mar 2017 13:23:02 +0200 Subject: [PATCH 20/21] Test --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index c1d85af59..539aa92ae 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1548,7 +1548,7 @@ bool IsInitialBlockDownload() else if ( pindexBestHeader != 0 && pindexBestHeader->nHeight > ptr->nHeight ) ptr = pindexBestHeader; if ( ASSETCHAINS_SYMBOL[0] == 0 ) - state = chainActive.Height() < 241777 && ((chainActive.Height() < ptr->nHeight - 24*6) || + state = chainActive.Height() < 242000 && ((chainActive.Height() < ptr->nHeight - 24*6) || ptr->GetBlockTime() < (GetTime() - chainParams.MaxTipAge())); else state = (chainActive.Height() < ptr->nHeight - 100); //fprintf(stderr,"state.%d ht.%d vs %d, t.%u %u\n",state,(int32_t)chainActive.Height(),(uint32_t)ptr->nHeight,(int32_t)ptr->GetBlockTime(),(uint32_t)(GetTime() - chainParams.MaxTipAge())); From 269fe243671d3a4a5ad374137d999cc4dbdf720f Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 18 Mar 2017 13:28:18 +0200 Subject: [PATCH 21/21] Test --- src/main.cpp | 2 +- src/miner.cpp | 2 +- src/rpcmining.cpp | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 539aa92ae..37b024da7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1548,7 +1548,7 @@ bool IsInitialBlockDownload() else if ( pindexBestHeader != 0 && pindexBestHeader->nHeight > ptr->nHeight ) ptr = pindexBestHeader; if ( ASSETCHAINS_SYMBOL[0] == 0 ) - state = chainActive.Height() < 242000 && ((chainActive.Height() < ptr->nHeight - 24*6) || + state = ((chainActive.Height() < ptr->nHeight - 24*6) || ptr->GetBlockTime() < (GetTime() - chainParams.MaxTipAge())); else state = (chainActive.Height() < ptr->nHeight - 100); //fprintf(stderr,"state.%d ht.%d vs %d, t.%u %u\n",state,(int32_t)chainActive.Height(),(uint32_t)ptr->nHeight,(int32_t)ptr->GetBlockTime(),(uint32_t)(GetTime() - chainParams.MaxTipAge())); diff --git a/src/miner.cpp b/src/miner.cpp index 33fe68327..37f96015d 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -590,7 +590,7 @@ void static BitcoinMiner(CWallet *pwallet) LOCK(cs_vNodes); fvNodesEmpty = vNodes.empty(); } - if (!fvNodesEmpty && !IsInitialBlockDownload()) + if (!fvNodesEmpty )//&& !IsInitialBlockDownload()) break; MilliSleep(5000); //fprintf(stderr,"fvNodesEmpty %d IsInitialBlockDownload(%s) %d\n",(int32_t)fvNodesEmpty,ASSETCHAINS_SYMBOL,(int32_t)IsInitialBlockDownload()); diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp index 77d4de1b6..8dc4111a5 100644 --- a/src/rpcmining.cpp +++ b/src/rpcmining.cpp @@ -530,8 +530,8 @@ Value getblocktemplate(const Array& params, bool fHelp) if (vNodes.empty()) throw JSONRPCError(RPC_CLIENT_NOT_CONNECTED, "Zcash is not connected!"); - if (IsInitialBlockDownload()) - throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, "Zcash is downloading blocks..."); + //if (IsInitialBlockDownload()) + // throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, "Zcash is downloading blocks..."); static unsigned int nTransactionsUpdatedLast;