Update adaptivepow to handle variable block times

This commit is contained in:
jl777
2019-07-29 21:25:49 -11:00
parent b55da04025
commit 02e6851870
4 changed files with 27 additions and 31 deletions

View File

@@ -454,21 +454,7 @@ bool CheckProofOfWork(const CBlockHeader &blkHeader, uint8_t *pubkey33, int32_t
bnTarget.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow);
}
else if ( ASSETCHAINS_ADAPTIVEPOW != 0 && ASSETCHAINS_STAKED == 0 )
{
arith_uint256 origtarget;
uint32_t elapsed = (blkHeader.nTime - komodo_heightstamp(height-1));
if ( elapsed > 777 )
{
elapsed -= 777;
origtarget = bnTarget;
bnTarget = bnTarget * arith_uint256(elapsed * elapsed);
if ( bnTarget < origtarget ) // deal with underflow
{
bnTarget.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow);
fprintf(stderr,"underflowed, set to mindiff\n");
} else fprintf(stderr,"elapsed %d, adjust by factor of %d\n",elapsed+777,elapsed*elapsed);
}
}
bnTarget = komodo_adaptivepow_target(height,bnTarget,blkHeader.nTime);
// Check proof of work matches claimed amount
if ( UintToArith256(hash = blkHeader.GetHash()) > bnTarget && !blkHeader.IsVerusPOSBlock() )
{