From a912c7e8f2d3fc4432dec712ff71ce1a8300fae5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 7 Sep 2018 00:11:21 -1100 Subject: [PATCH] Test --- src/cc/oracles.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/cc/oracles.cpp b/src/cc/oracles.cpp index bd0411885..9f6edb137 100644 --- a/src/cc/oracles.cpp +++ b/src/cc/oracles.cpp @@ -412,11 +412,11 @@ int64_t OracleCorrelatedPrice(int32_t height,std::vector origprices) std::vector sorted; int32_t i,n; int64_t *prices,price; if ( (n= origprices.size()) == 1 ) return(origprices[0]); - sorted = origprices.sorted(); - prices = calloc(n,sizeof(*prices)); + std::sort(origprices.begin(), origprices.end()); + prices = (int64_t *)calloc(n,sizeof(*prices)); i = 0; for (std::vector::const_iterator it=sorted.begin(); it!=sorted.end(); it++) - prices[i++] = it->first; + prices[i++] = *it; price = correlate_price(height,prices,i); free(prices); return(price); @@ -430,7 +430,7 @@ int32_t oracleprice_add(std::vector &publishers,CPubKey if ( pk == it->pk ) { flag = 1; - if (height > it->height ) + if ( height > it->height ) { it->height = height; it->data = data; @@ -451,7 +451,7 @@ int32_t oracleprice_add(std::vector &publishers,CPubKey int64_t OraclePrice(int32_t height,uint256 reforacletxid,char *markeraddr,char *format) { std::vector > unspentOutputs; - CTransaction regtx,tx; uint256 hash,txid,oracletxid,batontxid; CPubKey pk; int32_t i,ht,height,maxheight=0; int64_t datafee,price; char batonaddr[64]; std::vector data; struct CCcontract_info *cp,C; std::vector publishers; std::vector prices; + CTransaction regtx,tx; uint256 hash,txid,oracletxid,batontxid; CPubKey pk; int32_t i,ht,maxheight=0; int64_t datafee,price; char batonaddr[64]; std::vector data; struct CCcontract_info *cp,C; std::vector publishers; std::vector prices; if ( format[0] != 'L' ) return(0); cp = CCinit(&C,EVAL_ORACLES); @@ -459,14 +459,14 @@ int64_t OraclePrice(int32_t height,uint256 reforacletxid,char *markeraddr,char * for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; - height = (int32_t)it->second.blockHeight; + ht = (int32_t)it->second.blockHeight; if ( myGetTransaction(txid,regtx,hash) != 0 ) { if ( regtx.vout.size() > 0 && DecodeOraclesOpRet(regtx.vout[regtx.vout.size()-1].scriptPubKey,oracletxid,pk,datafee) == 'R' && oracletxid == reforacletxid ) { Getscriptaddress(batonaddr,regtx.vout[1].scriptPubKey); batontxid = OracleBatonUtxo(10000,cp,oracletxid,batonaddr,pk,data); - if ( batontxid != zeroid && (ht= oracleprice_add(publishers,pk,height,data,maxheight)) > maxht ) + if ( batontxid != zeroid && (ht= oracleprice_add(publishers,pk,ht,data,maxheight)) > maxheight ) maxheight = ht; } } @@ -482,7 +482,7 @@ int64_t OraclePrice(int32_t height,uint256 reforacletxid,char *markeraddr,char * prices.push_back(price); } } - return(OracleCorrelatedPrice(maxheight,prices)); + return(OracleCorrelatedPrice(height,prices)); } return(0); }