Overflow fixes?

This commit is contained in:
jl777
2019-08-07 11:08:39 -11:00
parent d1767f967d
commit 0a04ce6009

View File

@@ -349,13 +349,13 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead
if ( ASSETCHAINS_ADAPTIVEPOW == 1 ) // TSA if ( ASSETCHAINS_ADAPTIVEPOW == 1 ) // TSA
{ {
arith_uint256 A,B,C; // fix overflow bug on diff stranding arith_uint256 A,B,C; // fix overflow bug on diff stranding
if ( tipdiff < 2 ) if ( tipdiff < 3 )
tipdiff = 2; tipdiff = 3;
bnTarget = ct[0] / arith_uint256(K*T); bnTarget = ct[0] / arith_uint256(K*T);
A = bnTarget * arith_uint256(T); A = bnTarget * arith_uint256(T);
B = (bnTarget / arith_uint256(360000)) * arith_uint256(tipdiff * zawy_exponential_val360000(tipdiff/2)); B = (bnTarget / arith_uint256(360000)) * arith_uint256(tipdiff * zawy_exponential_val360000(tipdiff*5/9));
C = (bnTarget / arith_uint256(360000)) * arith_uint256(T * zawy_exponential_val360000(tipdiff/2)); C = (bnTarget / arith_uint256(360000)) * arith_uint256(T * zawy_exponential_val360000(tipdiff*5/9));
bnTarget = (A + B - C) * arith_uint256(K*T) / arith_uint256(tipdiff); bnTarget = ((A + B - C) / arith_uint256(tipdiff)) * arith_uint256(K*T);
{ {
int32_t z; int32_t z;
for (z=31; z>=0; z--) for (z=31; z>=0; z--)