From 0a04ce6009b4754eca1dc14a2bdf27eaae10f5c1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Aug 2019 11:08:39 -1100 Subject: [PATCH] Overflow fixes? --- src/pow.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/pow.cpp b/src/pow.cpp index 2630450bb..c832b3287 100644 --- a/src/pow.cpp +++ b/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--)