From ae67e0923cf3dc1ba3850b0999fea0700f6f0c65 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 11 Jul 2018 10:58:42 -1100 Subject: [PATCH 1/2] Fix PoS estimator for first 100 blocks --- src/komodo_bitcoind.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index afd1fe46e..6656b8e25 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1293,7 +1293,6 @@ arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t he fprintf(stderr,"1"); sum += UintToArith256(pindex->GetBlockHash()); m++; - n++; } } /*if ( (pindex= komodo_chainactive(ht)) != 0 ) From b6c80e46e31b3833d589a9699d91ff833ab89846 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 11 Jul 2018 11:06:05 -1100 Subject: [PATCH 2/2] Test --- src/komodo_bitcoind.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 6656b8e25..c48413575 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1348,10 +1348,11 @@ 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 = (ave * arith_uint256(percPoS * percPoS * percPoS)) / arith_uint256(goalperc * goalperc); - if ( bnTarget > easydiff || bnTarget < ave ) + if ( bnTarget > easydiff ) bnTarget = easydiff; + else if ( bnTarget < ave ) // overflow + bnTarget = ((ave * arith_uint256(goalperc)) + (easydiff * arith_uint256(percPoS))) / arith_uint256(percPoS + goalperc); if ( 1 ) { for (i=31; i>=24; i--)