Browse Source

Overflow fixes?

pull/37/head
jl777 5 years ago
parent
commit
0a04ce6009
  1. 10
      src/pow.cpp

10
src/pow.cpp

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

Loading…
Cancel
Save