Fix zawyMA calc

This commit is contained in:
jl777
2019-08-03 03:12:13 -11:00
parent 31ebd139b8
commit cdb3980abc

View File

@@ -42,10 +42,10 @@ uint32_t komodo_chainactive_timestamp();
unsigned int lwmaGetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock, const Consensus::Params& params); unsigned int lwmaGetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock, const Consensus::Params& params);
unsigned int lwmaCalculateNextWorkRequired(const CBlockIndex* pindexLast, const Consensus::Params& params); unsigned int lwmaCalculateNextWorkRequired(const CBlockIndex* pindexLast, const Consensus::Params& params);
arith_uint256 zawy_targetMA(arith_uint256 easy,arith_uint256 bnTarget,int32_t divisor) arith_uint256 zawy_targetMA(arith_uint256 easy,arith_uint256 bnTarget,int32_t numerator)
{ {
bnTarget /= arith_uint256(divisor); bnTarget /= arith_uint256(ASSETCHAINS_BLOCKTIME);
bnTarget *= arith_uint256(ASSETCHAINS_BLOCKTIME); bnTarget *= arith_uint256(numerator);
if ( bnTarget > easy ) if ( bnTarget > easy )
bnTarget = easy; bnTarget = easy;
return(bnTarget); return(bnTarget);
@@ -166,7 +166,7 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead
} }
else if ( block12diff != 0 && block7diff != 0 && block4diff != 0 ) else if ( block12diff != 0 && block7diff != 0 && block4diff != 0 )
{ {
if ( block4diff > 4 && block4diff < ASSETCHAINS_BLOCKTIME/2 ) // for 10x and higher hashrate increases if ( (0) && block4diff > 4 && block4diff < ASSETCHAINS_BLOCKTIME/2 ) // added /2
{ {
block4diff += (2 * ASSETCHAINS_BLOCKTIME) / 3; block4diff += (2 * ASSETCHAINS_BLOCKTIME) / 3;
bnTarget = bnTarget * arith_uint256(block4diff) / arith_uint256(ASSETCHAINS_BLOCKTIME * 2); bnTarget = bnTarget * arith_uint256(block4diff) / arith_uint256(ASSETCHAINS_BLOCKTIME * 2);