diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp index cf9b1c20c..e293d6926 100644 --- a/src/bitcoind.cpp +++ b/src/bitcoind.cpp @@ -83,7 +83,7 @@ void WaitForShutdown(boost::thread_group* threadGroup) ASSETCHAINS_ADAPTIVEPOW = 1; fprintf(stderr,"default activate adaptivepow\n"); } else fprintf(stderr,"height1 time %u vs %u\n",pindex->nTime,ADAPTIVEPOW_CHANGETO_DEFAULTON); - } else fprintf(stderr,"cant find height 1\n"); + } //else fprintf(stderr,"cant find height 1\n"); if ( ASSETCHAINS_CBOPRET != 0 ) komodo_pricesinit(); while (!fShutdown) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 95f609483..84a84935b 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1424,8 +1424,8 @@ arith_uint256 komodo_adaptivepow_target(int32_t height,arith_uint256 bnTarget,ui diff = (nTime - tipindex->GetMedianTimePast()); tipdiff = (nTime - tipindex->nTime); if ( tipdiff > 13*ASSETCHAINS_BLOCKTIME ) - diff = 13*ASSETCHAINS_BLOCKTIME; - if ( diff > 13 * ASSETCHAINS_BLOCKTIME ) + diff = tipdiff; + if ( diff >= 13 * ASSETCHAINS_BLOCKTIME ) { mult = diff - 12 * ASSETCHAINS_BLOCKTIME; mult = (mult / ASSETCHAINS_BLOCKTIME) * ASSETCHAINS_BLOCKTIME + ASSETCHAINS_BLOCKTIME / 2; @@ -1435,10 +1435,10 @@ arith_uint256 komodo_adaptivepow_target(int32_t height,arith_uint256 bnTarget,ui if ( bnTarget < origtarget || bnTarget > easy ) // deal with overflow { bnTarget = easy; - fprintf(stderr,"miner overflowed mult.%lld, set to mindiff\n",(long long)mult); - } else fprintf(stderr,"miner elapsed %d, adjust by factor of %lld\n",diff,(long long)mult); - } else fprintf(stderr,"diff %d, vs 120\n",diff); - } else fprintf(stderr,"cant find height.%d\n",height); + fprintf(stderr,"tipdiff.%d diff.%d height.%d miner overflowed mult.%lld, set to mindiff\n",tipdiff,diff,height,(long long)mult); + } else fprintf(stderr,"tipdiff.%d diff.%d height.%d miner elapsed %d, adjust by factor of %lld\n",tipdiff,diff,height,diff,(long long)mult); + } //else fprintf(stderr,"height.%d tipdiff.%d diff %d, vs %d\n",height,tipdiff,diff,13*ASSETCHAINS_BLOCKTIME); + } else fprintf(stderr,"adaptive cant find height.%d\n",height); return(bnTarget); } diff --git a/src/miner.cpp b/src/miner.cpp index 05a24ca2f..6d404161f 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -2041,7 +2041,10 @@ void static BitcoinMiner() pblock->nNonce = ArithToUint256(UintToArith256(pblock->nNonce) + 1); pblock->nBits = savebits; if ( ASSETCHAINS_ADAPTIVEPOW > 0 ) + { UpdateTime(pblock, chainparams.GetConsensus(), pindexPrev); + hashTarget = HASHTarget_POW = komodo_adaptivepow_target(Mining_height,HASHTarget,pblock->nTime); + } /*if ( NOTARY_PUBKEY33[0] == 0 ) { int32_t percPoS;