Browse Source

Test

etomic
jl777 8 years ago
parent
commit
e75f8eb260
  1. 2
      iguana/exchanges/LP_ordermatch.c
  2. 17
      iguana/exchanges/LP_prices.c

2
iguana/exchanges/LP_ordermatch.c

@ -170,7 +170,7 @@ char *LP_quotereceived(cJSON *argjson)
if ( (ptr= LP_cacheadd(Q.srccoin,Q.destcoin,Q.txid,Q.vout,price,&Q)) != 0 )
{
ptr->Q = Q;
printf("\n>>>>>>>>>> received.(%s) quote %.8f\n\n",jprint(argjson,0),price);
printf("\n>>>>>>>>>> received quote %.8f\n\n",price);
return(clonestr("{\"result\":\"updated\"}"));
} else return(clonestr("{\"error\":\"nullptr\"}"));
}

17
iguana/exchanges/LP_prices.c

@ -453,9 +453,9 @@ static int _cmp_orderbook(const void *a,const void *b)
#define ptr_a (*(struct LP_orderbookentry **)a)->price
#define ptr_b (*(struct LP_orderbookentry **)b)->price
if ( ptr_b > ptr_a )
retval = 1;
else if ( ptr_b < ptr_a )
retval = -1;
else if ( ptr_b < ptr_a )
retval = 1;
else
{
#undef ptr_a
@ -463,9 +463,9 @@ static int _cmp_orderbook(const void *a,const void *b)
#define ptr_a ((struct LP_orderbookentry *)a)->basesatoshis
#define ptr_b ((struct LP_orderbookentry *)b)->basesatoshis
if ( ptr_b > ptr_a )
return(1);
else if ( ptr_b < ptr_a )
return(-1);
else if ( ptr_b < ptr_a )
return(1);
}
// printf("%.8f vs %.8f -> %d\n",ptr_a,ptr_b,retval);
return(retval);
@ -473,11 +473,6 @@ static int _cmp_orderbook(const void *a,const void *b)
#undef ptr_b
}
static int _cmp_orderbookrev(const void *a,const void *b)
{
return(-_cmp_orderbook(a,b));
}
cJSON *LP_orderbookjson(struct LP_orderbookentry *op)
{
cJSON *item = cJSON_CreateObject();
@ -603,13 +598,13 @@ char *LP_orderbook(char *base,char *rel)
retjson = cJSON_CreateObject();
array = cJSON_CreateArray();
if ( numbids > 1 )
qsort(bids,numbids,sizeof(*bids),_cmp_orderbookrev);
qsort(bids,numbids,sizeof(*bids),_cmp_orderbook);
if ( numasks > 1 )
{
for (i=0; i<numasks; i++)
printf("%.8f ",asks[i]->price);
printf(" -> ");
qsort(asks,numasks,sizeof(*asks),_cmp_orderbookrev);
qsort(asks,numasks,sizeof(*asks),_cmp_orderbook);
for (i=0; i<numasks; i++)
printf("%.8f ",asks[i]->price);
printf("sorted asks.%d\n",numasks);

Loading…
Cancel
Save