From 9b565ea675e39a68214e51ee64cd992d38f81305 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 3 Apr 2019 07:00:43 -1100 Subject: [PATCH] Handle early block prices --- src/rpc/blockchain.cpp | 42 ++++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 5f1d671e4..ce27238a9 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1188,7 +1188,7 @@ UniValue prices(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 1 ) throw runtime_error("prices maxsamples\n"); LOCK(cs_main); - UniValue ret(UniValue::VOBJ); uint64_t seed,rngval; int64_t smoothed,*correlated,*correlated2; char name[64],*str; uint32_t rawprices[1440*6],*prices,*prices2; uint32_t i,width,j,numpricefeeds=-1,n,nextheight,offset,ht,num=0,daywindow = (3600*24/ASSETCHAINS_BLOCKTIME) + 1; + UniValue ret(UniValue::VOBJ); uint64_t seed,rngval; int64_t smoothed,*correlated,*correlated2; char name[64],*str; uint32_t rawprices[1440*6],*prices,*prices2; uint32_t i,width,j,numpricefeeds=-1,n,num,nextheight,offset,ht,num=0,daywindow = (3600*24/ASSETCHAINS_BLOCKTIME) + 1; if ( ASSETCHAINS_CBOPRET == 0 ) throw JSONRPCError(RPC_INVALID_PARAMETER, "only -ac_cbopret chains have prices"); @@ -1225,6 +1225,7 @@ UniValue prices(const UniValue& params, bool fHelp) } else throw JSONRPCError(RPC_INVALID_PARAMETER, "no komodo_rawprices found"); } } + num = i; ret.push_back(Pair("firstheight", (int64_t)nextheight-1-i)); UniValue timestamps(UniValue::VARR); for (i=0; i= width ) { - offset = j*width + i; - rngval = (rngval*11109 + 13849); - if ( (correlated[i]= komodo_pricecorrelated(rngval,j,&prices[offset],daywindow,prices2,smoothwidth)) < 0 ) - throw JSONRPCError(RPC_INVALID_PARAMETER, "null correlated price"); + for (i=0; i