|
|
@ -1293,6 +1293,7 @@ uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeigh |
|
|
|
|
|
|
|
arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t height,int32_t goalperc) |
|
|
|
{ |
|
|
|
int32_t oldflag = 0; |
|
|
|
CBlockIndex *pindex; arith_uint256 easydiff,bnTarget,hashval,sum,ave; bool fNegative,fOverflow; int32_t i,n,m,ht,percPoS,diff,val; |
|
|
|
*percPoSp = percPoS = 0; |
|
|
|
if ( height <= 10 || (ASSETCHAINS_STAKED == 100 && height <= 100) ) |
|
|
@ -1361,8 +1362,9 @@ arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t he |
|
|
|
percPoS = 1; |
|
|
|
if ( percPoS < goalperc ) // increase PoW diff -> lower bnTarget
|
|
|
|
{ |
|
|
|
//bnTarget = (ave * arith_uint256(percPoS * percPoS)) / arith_uint256(goalperc * goalperc * goalperc);
|
|
|
|
bnTarget = (ave / arith_uint256(goalperc * goalperc * goalperc)) * arith_uint256(percPoS * percPoS); |
|
|
|
if ( oldflag != 0 ) |
|
|
|
bnTarget = (ave * arith_uint256(percPoS * percPoS)) / arith_uint256(goalperc * goalperc * goalperc); |
|
|
|
else bnTarget = (ave / arith_uint256(goalperc * goalperc * goalperc)) * arith_uint256(percPoS * percPoS); |
|
|
|
if ( ASSETCHAINS_STAKED < 100 ) |
|
|
|
{ |
|
|
|
for (i=31; i>=24; i--) |
|
|
@ -1378,10 +1380,12 @@ arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t he |
|
|
|
} |
|
|
|
else if ( percPoS > goalperc ) // decrease PoW diff -> raise bnTarget
|
|
|
|
{ |
|
|
|
//bnTarget = ((ave * arith_uint256(goalperc)) + (easydiff * arith_uint256(percPoS))) / arith_uint256(percPoS + goalperc);
|
|
|
|
//bnTarget = (bnTarget * arith_uint256(percPoS * percPoS * percPoS)) / arith_uint256(goalperc * goalperc);
|
|
|
|
bnTarget = (bnTarget / arith_uint256(goalperc * goalperc)) * arith_uint256(percPoS * percPoS * percPoS); |
|
|
|
|
|
|
|
if ( oldflag != 0 ) |
|
|
|
{ |
|
|
|
bnTarget = ((ave * arith_uint256(goalperc)) + (easydiff * arith_uint256(percPoS))) / arith_uint256(percPoS + goalperc); |
|
|
|
//bnTarget = (bnTarget * arith_uint256(percPoS * percPoS * percPoS)) / arith_uint256(goalperc * goalperc);
|
|
|
|
bnTarget = (bnTarget / arith_uint256(goalperc * goalperc)) * arith_uint256(percPoS * percPoS * percPoS); |
|
|
|
} else bnTarget = (bnTarget / arith_uint256(goalperc * goalperc)) * arith_uint256(percPoS * percPoS * percPoS); |
|
|
|
if ( bnTarget > easydiff ) |
|
|
|
bnTarget = easydiff; |
|
|
|
else if ( bnTarget < ave ) // overflow
|
|
|
|