From b088fa97297f2589c4777fc4ffb9cbaa865fcd11 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 19 Jul 2018 22:22:30 -1100 Subject: [PATCH] Fix PoW diff check in PoS/PoW mode --- src/komodo_bitcoind.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 2bc4e1b88..516f31187 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1481,11 +1481,13 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) bnTarget.SetCompact(pblock->nBits,&fNegative,&fOverflow); bhash = UintToArith256(hash); possible = komodo_block2pubkey33(pubkey33,pblock); - //fprintf(stderr,"height.%d slowflag.%d possible.%d cmp.%d\n",height,slowflag,possible,bhash > bnTarget); if ( height == 0 ) { if ( slowflag != 0 ) + { + fprintf(stderr,"height.%d slowflag.%d possible.%d cmp.%d\n",height,slowflag,possible,bhash > bnTarget); return(0); + } if ( (pprev= mapBlockIndex[pblock->hashPrevBlock]) != 0 ) height = pprev->nHeight + 1; if ( height == 0 ) @@ -1535,10 +1537,14 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) fprintf(stderr,"%02x",((uint8_t *)&bnTarget)[i]); fprintf(stderr," ht.%d PoW diff violation PoSperc.%d vs goalperc.%d\n",height,PoSperc,(int32_t)ASSETCHAINS_STAKED); return(-1); - } + } else failed = 0; } - } else if ( is_PoSblock < 0 ) + } + else if ( is_PoSblock < 0 ) + { + fprintf(stderr,"unexpected negative is_PoSblock.%d\n",is_PoSblock); return(-1); + } } if ( failed == 0 && ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 ) {