From 3f99059c5463ed688dc3f6ec1a8b7f9d447a37cc Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 5 Dec 2017 15:13:08 +0400 Subject: [PATCH] Test --- iguana/exchanges/LP_prices.c | 53 ++++++++++++++++-------------- iguana/exchanges/LP_statemachine.c | 24 ++++++++++++++ iguana/exchanges/stats.c | 4 ++- 3 files changed, 56 insertions(+), 25 deletions(-) diff --git a/iguana/exchanges/LP_prices.c b/iguana/exchanges/LP_prices.c index 16efbe735..587efe5ff 100644 --- a/iguana/exchanges/LP_prices.c +++ b/iguana/exchanges/LP_prices.c @@ -908,30 +908,6 @@ int64_t LP_KMDvalue(struct iguana_info *coin,int64_t balance) { if ( strcmp(coin->symbol,"KMD") == 0 ) KMDvalue = balance; - /*else if ( (retstr= LP_orderbook(coin->symbol,"KMD",-1)) != 0 ) - { - if ( (orderbook= cJSON_Parse(retstr)) != 0 ) - { - if ( (asks= jarray(&numasks,orderbook,"asks")) != 0 && numasks > 0 ) - { - item = jitem(asks,0); - price = ask = jdouble(item,"price"); - //printf("%s/%s ask %.8f\n",coin->symbol,"KMD",ask); - } - if ( (bids= jarray(&numbids,orderbook,"bids")) != 0 && numbids > 0 ) - { - item = jitem(asks,0); - bid = jdouble(item,"price"); - if ( price == 0. ) - price = bid; - else price = (bid + ask) * 0.5; - //printf("%s/%s bid %.8f ask %.8f price %.8f\n",coin->symbol,"KMD",bid,ask,price); - } - KMDvalue = price * balance; - free_json(orderbook); - } - free(retstr); - }*/ else { price = LP_price(coin->symbol,"KMD"); @@ -1138,3 +1114,32 @@ void LP_pricefeedupdate(bits256 pubkey,char *base,char *rel,double price,char *u // printf("error finding %s/%s %.8f\n",base,rel,price); } +cJSON *LP_fundvalue(cJSON *argjson) +{ + cJSON *holdings,*item,*newitem; int32_t i,n; double btcprice,balance,btcsum; struct iguana_info *coin; char *symbol; int64_t fundvalue,KMDvalue = 0; + fundvalue = 0; + btcsum = 0.; + if ( (holdings= jarray(&n,argjson,"holdings")) != 0 ) + { + for (i=0; i SMALLVAL ) + { + item = cJSON_CreateObject(); + jaddstr(item,"coin",symbol); + if ( (coin= LP_coinfind(symbol)) != 0 && (KMDvalue= LP_KMDvalue(coin,SATOSHIDEN * balance)) > 0 ) + { + jaddnum(item,"KMD",dstr(KMDvalue)); + fundvalue += KMDvalue; + } + else if ( (btcprice= LP_CMCbtcprice(symbol)) > SMALLVAL ) + { + btcsum += btcprice * balance; + jaddnum(item,"BTC",btcprice * balance); + } + } + } + } +} + diff --git a/iguana/exchanges/LP_statemachine.c b/iguana/exchanges/LP_statemachine.c index bb3754605..d970974e8 100644 --- a/iguana/exchanges/LP_statemachine.c +++ b/iguana/exchanges/LP_statemachine.c @@ -2094,6 +2094,30 @@ char *LP_postutxos_recv(cJSON *argjson) } return(clonestr("{\"error\":\"sig failure\"}")); } +/*else if ( (retstr= LP_orderbook(coin->symbol,"KMD",-1)) != 0 ) + { + if ( (orderbook= cJSON_Parse(retstr)) != 0 ) + { + if ( (asks= jarray(&numasks,orderbook,"asks")) != 0 && numasks > 0 ) + { + item = jitem(asks,0); + price = ask = jdouble(item,"price"); + //printf("%s/%s ask %.8f\n",coin->symbol,"KMD",ask); + } + if ( (bids= jarray(&numbids,orderbook,"bids")) != 0 && numbids > 0 ) + { + item = jitem(asks,0); + bid = jdouble(item,"price"); + if ( price == 0. ) + price = bid; + else price = (bid + ask) * 0.5; + //printf("%s/%s bid %.8f ask %.8f price %.8f\n",coin->symbol,"KMD",bid,ask,price); + } + KMDvalue = price * balance; + free_json(orderbook); + } + free(retstr); + }*/ int32_t LP_utxosQ_process() { diff --git a/iguana/exchanges/stats.c b/iguana/exchanges/stats.c index 0241f66ac..06a44a920 100644 --- a/iguana/exchanges/stats.c +++ b/iguana/exchanges/stats.c @@ -817,7 +817,9 @@ void stats_rpcloop(void *args) } #endif*/ memcpy(&ipbits,&cli_addr.sin_addr.s_addr,sizeof(ipbits)); - if ( DOCKERFLAG == 0 && port == RPC_port && ipbits != localhostbits ) + if ( DOCKERFLAG != 0 ) + ipbits = localhostbits; + if ( port == RPC_port && ipbits != localhostbits ) { //printf("port.%u RPC_port.%u ipbits %x != %x\n",port,RPC_port,ipbits,localhostbits); closesocket(sock);