Use tipdiff also

This commit is contained in:
jl777
2019-07-30 04:50:27 -11:00
parent 91ce4a99e6
commit 8fbb317419
2 changed files with 5 additions and 2 deletions

View File

@@ -82,7 +82,7 @@ void WaitForShutdown(boost::thread_group* threadGroup)
{ {
ASSETCHAINS_ADAPTIVEPOW = 1; ASSETCHAINS_ADAPTIVEPOW = 1;
fprintf(stderr,"default activate adaptivepow\n"); fprintf(stderr,"default activate adaptivepow\n");
} else fprintf(stderr,"height1 time %u vs %u\n",pindex->nTime,1564499104-365*2*1440) } else fprintf(stderr,"height1 time %u vs %u\n",pindex->nTime,1564499104-365*2*1440);
} else fprintf(stderr,"cant find height 1\n"); } else fprintf(stderr,"cant find height 1\n");
if ( ASSETCHAINS_CBOPRET != 0 ) if ( ASSETCHAINS_CBOPRET != 0 )
komodo_pricesinit(); komodo_pricesinit();

View File

@@ -1418,10 +1418,13 @@ uint32_t komodo_stakehash(uint256 *hashp,char *address,uint8_t *hashbuf,uint256
arith_uint256 komodo_adaptivepow_target(int32_t height,arith_uint256 bnTarget,uint32_t nTime) arith_uint256 komodo_adaptivepow_target(int32_t height,arith_uint256 bnTarget,uint32_t nTime)
{ {
arith_uint256 origtarget,easy; int32_t diff; int64_t mult; bool fNegative,fOverflow; CBlockIndex *tipindex; arith_uint256 origtarget,easy; int32_t diff,tipdiff; int64_t mult; bool fNegative,fOverflow; CBlockIndex *tipindex;
if ( height > 10 && (tipindex= komodo_chainactive(height - 1)) != 0 ) if ( height > 10 && (tipindex= komodo_chainactive(height - 1)) != 0 )
{ {
diff = (nTime - tipindex->GetMedianTimePast()); diff = (nTime - tipindex->GetMedianTimePast());
tipdiff = (nTime - tipindex->nTime);
if ( tipdiff > 13*ASSETCHAINS_BLOCKTIME )
diff = 13*ASSETCHAINS_BLOCKTIME;
if ( diff > 20 * ASSETCHAINS_BLOCKTIME ) if ( diff > 20 * ASSETCHAINS_BLOCKTIME )
{ {
mult = diff - 19 * ASSETCHAINS_BLOCKTIME; mult = diff - 19 * ASSETCHAINS_BLOCKTIME;