From 81df6aeabdca4f7cbcfbe77cbe054524ab38399e Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 18 Jan 2019 01:16:41 -1100 Subject: [PATCH] Sort utxo gals --- src/cc/marmara.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 5c8bca482..17d1aa6c8 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -365,7 +365,7 @@ int64_t AddMarmaraCoinbases(struct CCcontract_info *cp,CMutableTransaction &mtx, int64_t AddMarmarainputs(CMutableTransaction &mtx,std::vector &pubkeys,char *coinaddr,int64_t total,int32_t maxinputs) { - uint64_t threshold,nValue,totalinputs = 0; uint256 txid,hashBlock; CTransaction tx; int32_t numvouts,ht,unlockht,vout,n = 0; uint8_t funcid; CPubKey pk; + uint64_t threshold,nValue,totalinputs = 0; uint256 txid,hashBlock; CTransaction tx; int32_t numvouts,ht,unlockht,vout,i,n = 0; uint8_t funcid; CPubKey pk; std::vector vals; std::vector > unspentOutputs; SetCCunspents(unspentOutputs,coinaddr); threshold = total/(maxinputs+1); @@ -373,7 +373,6 @@ int64_t AddMarmarainputs(CMutableTransaction &mtx,std::vector &pubkeys, { txid = it->first.txhash; vout = (int32_t)it->first.index; - char str[64]; fprintf(stderr,"(%s) %s/v%d %.8f\n",coinaddr,uint256_str(str,txid),vout,(double)it->second.satoshis/COIN); if ( it->second.satoshis < threshold ) continue; if ( GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 0 && vout < numvouts && tx.vout[vout].scriptPubKey.IsPayToCryptoCondition() != 0 && myIsutxo_spentinmempool(txid,vout) == 0 ) @@ -387,12 +386,20 @@ int64_t AddMarmarainputs(CMutableTransaction &mtx,std::vector &pubkeys, pubkeys.push_back(pk); } totalinputs += it->second.satoshis; + vals.push_back(it->second.satoshis); n++; if ( (total > 0 && totalinputs >= total) || (maxinputs > 0 && n >= maxinputs) ) break; } else fprintf(stderr,"null funcid\n"); } } + if ( maxinputs != 0 && total == 0 ) + { + std::sort(vals.begin(), vals.end()); + totalinputs = 0; + for (i=0; i