Browse Source

Test

etomic
jl777 7 years ago
parent
commit
3f99059c54
  1. 53
      iguana/exchanges/LP_prices.c
  2. 24
      iguana/exchanges/LP_statemachine.c
  3. 4
      iguana/exchanges/stats.c

53
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 ) if ( strcmp(coin->symbol,"KMD") == 0 )
KMDvalue = balance; 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 else
{ {
price = LP_price(coin->symbol,"KMD"); 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); // 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<n; i++)
{
item = jitem(holdings,i);
if ( (symbol= jstr(item,"coin")) != 0 && (balance= jdouble(item,"balance")) > 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);
}
}
}
}
}

24
iguana/exchanges/LP_statemachine.c

@ -2094,6 +2094,30 @@ char *LP_postutxos_recv(cJSON *argjson)
} }
return(clonestr("{\"error\":\"sig failure\"}")); 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() int32_t LP_utxosQ_process()
{ {

4
iguana/exchanges/stats.c

@ -817,7 +817,9 @@ void stats_rpcloop(void *args)
} }
#endif*/ #endif*/
memcpy(&ipbits,&cli_addr.sin_addr.s_addr,sizeof(ipbits)); 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); //printf("port.%u RPC_port.%u ipbits %x != %x\n",port,RPC_port,ipbits,localhostbits);
closesocket(sock); closesocket(sock);

Loading…
Cancel
Save