From e005f57633c3f198c821b5726b4ad3c60cd71d89 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 9 Apr 2018 21:12:25 +0300 Subject: [PATCH] Test --- src/komodo_gateway.h | 8 ++++---- src/wallet/rpcwallet.cpp | 17 ++++++++++------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index a9cf3edfc..367393fde 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -704,11 +704,11 @@ uint32_t komodo_stake(arith_uint256 bnTarget,int32_t nHeight,uint256 txid,int32_ } //fprintf(stderr,"iterated until i.%d winner.%d\n",i,winner); } - for (i=31; i>=0; i--) + for (i=31; i>=24; i--) fprintf(stderr,"%02x",((uint8_t *)&hashval)[i]); - //fprintf(stderr," vs "); - //for (i=31; i>=0; i--) - // fprintf(stderr,"%02x",((uint8_t *)&bnTarget)[i]); + fprintf(stderr," vs "); + for (i=31; i>=24; i--) + fprintf(stderr,"%02x",((uint8_t *)&bnTarget)[i]); fprintf(stderr," iter.%d winner.%d coinage.%llu %d ht.%d gap.%d %.8f/%llu\n",iter,winner,(long long)coinage,(int32_t)(blocktime - txtime),nHeight,(int32_t)(blocktime - prevtime),dstr(value),(long long)supply); } return(blocktime * winner); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index a52d7ab46..b31948013 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4492,14 +4492,17 @@ int32_t komodo_staked(uint32_t nBits,uint32_t *blocktimep,uint32_t *txtimep,uint if ( pindex != 0 && (tipindex= chainActive.Tip()) != 0 ) { eligible = komodo_stake(bnTarget,(uint32_t)tipindex->nHeight+1,out.tx->GetHash(),out.i,*blocktimep,(uint32_t)tipindex->nTime); - if ( (eligible > 0 && eligible < earliest) || (eligible == earliest && (*utxovaluep == 0 || nValue < *utxovaluep)) ) + if ( eligible > 0 ) { - earliest = eligible; - best_scriptPubKey = out.tx->vout[out.i].scriptPubKey; - *utxovaluep = (uint64_t)nValue; - decode_hex((uint8_t *)utxotxidp,32,(char *)out.tx->GetHash().GetHex().c_str()); - *utxovoutp = out.i; - *txtimep = (uint32_t)out.tx->nLockTime; + if ( earliest == 0 || eligible < earliest || (eligible == earliest && (*utxovaluep == 0 || nValue < *utxovaluep)) ) + { + earliest = eligible; + best_scriptPubKey = out.tx->vout[out.i].scriptPubKey; + *utxovaluep = (uint64_t)nValue; + decode_hex((uint8_t *)utxotxidp,32,(char *)out.tx->GetHash().GetHex().c_str()); + *utxovoutp = out.i; + *txtimep = (uint32_t)out.tx->nLockTime; + } } //fprintf(stderr,"(%s) %s/v%d nValue %.8f locktime.%u txheight.%d pindexht.%d\n",CBitcoinAddress(address).ToString().c_str(),out.tx->GetHash().GetHex().c_str(),out.i,(double)nValue/COIN,locktime,txheight,pindex->nHeight); }