From c023699ab502cff3cccd25d0ad52cd8f90906510 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 3 Dec 2016 11:28:36 -0300 Subject: [PATCH] test --- src/komodo_globals.h | 2 +- src/komodo_utils.h | 2 ++ src/main.cpp | 23 ++++++++++++----------- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index a17c29964..7c8b7126d 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -36,7 +36,7 @@ struct komodo_state KOMODO_STATES[34]; int COINBASE_MATURITY = 100; -int32_t IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE; +int32_t IS_KOMODO_NOTARY,KOMODO_REWIND,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE; std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES; uint8_t NOTARY_PUBKEY33[33]; diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 7b92d3a95..74a2a73f3 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1450,6 +1450,8 @@ void komodo_args() if ( strlen(NOTARY_PUBKEY.c_str()) == 66 ) USE_EXTERNAL_PUBKEY = 1; name = GetArg("-ac_name",""); + 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 af9484a03..fe832ac0f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2694,6 +2694,7 @@ 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(); @@ -2704,21 +2705,21 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo if (!DisconnectTip(state)) return false; } -if ( 1 ) -{ - static int32_t didinit; - if ( didinit++ == 0 ) + if ( KOMODO_REWIND != 0 && chainActive.Tip()->nHeight > KOMODO_REWIND ) { - while (chainActive.Tip()->nHeight > 94000 ) + static int32_t didinit; + if ( didinit++ == 0 ) { - fprintf(stderr,"rewind ht.%d\n",chainActive.Tip()->nHeight); - if ( !DisconnectTip(state) ) - return false; + while (chainActive.Tip()->nHeight > KOMODO_REWIND ) + { + fprintf(stderr,"rewind ht.%d\n",chainActive.Tip()->nHeight); + if ( !DisconnectTip(state) ) + 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;