diff --git a/src/init.cpp b/src/init.cpp index 2336a9101..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,7 +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; - if (!ActivateBestChain(state)) + if ( !ActivateBestChain(state)) strErrors << "Failed to connect best block"; std::vector vImportFiles; diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 5cdf8548a..556326102 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 ) { @@ -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); 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 825088d76..37b024da7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1548,8 +1548,8 @@ 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() < 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())); if (!state) @@ -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,30 +2768,28 @@ 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 ) { - //static int32_t didinit; - //if ( didinit++ == 0 ) - if ( chainActive.Tip()->nHeight == KOMODO_REWIND+1 ) + 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 ) { 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 ) - { - 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; bool fContinue = true; @@ -2868,7 +2865,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(); } 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/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/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; 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);