Update adaptivepow to handle variable block times
This commit is contained in:
16
src/pow.cpp
16
src/pow.cpp
@@ -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() )
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user