Browse Source

Test

etomic
jl777 8 years ago
parent
commit
7078125aea
  1. 18
      iguana/exchanges/LP_quotes.c
  2. 4
      iguana/exchanges/LP_utxos.c

18
iguana/exchanges/LP_quotes.c

@ -172,7 +172,7 @@ char *LP_quotereceived(cJSON *argjson)
if ( (ptr= LP_cacheadd(Q.srccoin,Q.destcoin,Q.txid,Q.vout,price,&Q)) != 0 )
{
ptr->Q = Q;
char str[65]; printf("received.(%s) quote %.8f\n",bits256_str(str,Q.txid),price);
//char str[65]; printf("received.(%s) quote %.8f\n",bits256_str(str,Q.txid),price);
return(clonestr("{\"result\":\"updated\"}"));
} else return(clonestr("{\"error\":\"nullptr\"}"));
}
@ -207,7 +207,7 @@ cJSON *LP_tradecandidates(struct LP_utxoinfo *myutxo,char *base)
totaladded = 0;
HASH_ITER(hh,LP_peerinfos,peer,tmp)
{
n = 0;
n = added = 0;
if ( (utxostr= issue_LP_clientgetutxos(peer->ipaddr,peer->port,base,100)) != 0 )
{
//printf("%s:%u %s %s\n",peer->ipaddr,peer->port,base,utxostr);
@ -216,7 +216,6 @@ cJSON *LP_tradecandidates(struct LP_utxoinfo *myutxo,char *base)
if ( is_cJSON_Array(array) != 0 && (n= cJSON_GetArraySize(array)) > 0 )
{
retarray = cJSON_CreateArray();
added = 0;
for (i=0; i<n; i++)
{
item = jitem(array,i);
@ -258,7 +257,7 @@ cJSON *LP_autotrade(struct LP_utxoinfo *myutxo,char *base,double maxprice)
maxprice = LP_price(base,myutxo->coin) / 0.975;
if ( (array= LP_tradecandidates(myutxo,base)) != 0 )
{
printf("candidates.(%s)\nn.%d\n",jprint(array,0),cJSON_GetArraySize(array));
//printf("candidates.(%s)\nn.%d\n",jprint(array,0),cJSON_GetArraySize(array));
if ( (n= cJSON_GetArraySize(array)) > 0 )
{
memset(prices,0,sizeof(prices));
@ -330,7 +329,14 @@ cJSON *LP_autotrade(struct LP_utxoinfo *myutxo,char *base,double maxprice)
jaddnum(bestitem,"requestid",R.requestid);
jaddnum(bestitem,"quoteid",R.quoteid);
printf("Alice r.%u q.%u\n",R.requestid,R.quoteid);
} else jaddstr(bestitem,"status","too expensive");
}
else
{
jaddstr(bestitem,"status","too expensive");
jaddnum(bestitem,"price",price);
jaddnum(bestitem,"maxprice",maxprice);
jaddnum(bestitem,"bestprice",bestprice);
}
}
}
}
@ -355,7 +361,7 @@ int32_t LP_priceping(int32_t pubsock,struct LP_utxoinfo *utxo,char *rel,double p
retjson = LP_quotejson(&Q);
jaddstr(retjson,"method","quote");
retstr = jprint(retjson,1);
printf("PING.(%s)\n",retstr);
//printf("PING.(%s)\n",retstr);
LP_send(pubsock,retstr,1);
utxo->published = now;
return(0);

4
iguana/exchanges/LP_utxos.c

@ -177,7 +177,7 @@ struct LP_utxoinfo *LP_addutxo(int32_t amclient,struct LP_peerinfo *mypeer,int32
else tmpsatoshis = value;
if ( (utxo= LP_utxofind(txid,vout)) != 0 )
{
printf("%.8f %.8f %.8f vs utxo.(%.8f %.8f %.8f)\n",dstr(value),dstr(value2),dstr(tmpsatoshis),dstr(utxo->value),dstr(utxo->value2),dstr(utxo->satoshis));
//printf("%.8f %.8f %.8f vs utxo.(%.8f %.8f %.8f)\n",dstr(value),dstr(value2),dstr(tmpsatoshis),dstr(utxo->value),dstr(utxo->value2),dstr(utxo->satoshis));
if ( bits256_cmp(txid,utxo->txid) != 0 || bits256_cmp(txid2,utxo->txid2) != 0 || vout != utxo->vout || value != utxo->value || tmpsatoshis != utxo->satoshis || vout2 != utxo->vout2 || value2 != utxo->value2 || strcmp(coin,utxo->coin) != 0 || strcmp(spendscript,utxo->spendscript) != 0 || strcmp(coinaddr,utxo->coinaddr) != 0 || strcmp(ipaddr,utxo->ipaddr) != 0 || port != utxo->port )
{
utxo->errors++;
@ -244,7 +244,7 @@ int32_t LP_utxosparse(int32_t amclient,struct LP_peerinfo *mypeer,int32_t mypubs
if ( jobj(item,"txid") != 0 )
{
txid = jbits256(item,"txid");
printf("parse.(%s)\n",jprint(item,0));
//printf("parse.(%s)\n",jprint(item,0));
utxo = LP_addutxo(amclient,mypeer,mypubsock,jstr(item,"coin"),txid,jint(item,"vout"),j64bits(item,"value"),jbits256(item,"txid2"),jint(item,"vout2"),j64bits(item,"value2"),jstr(item,"script"),jstr(item,"address"),argipaddr,argport,jdouble(item,"profit"));
if ( utxo != 0 )
utxo->lasttime = now;

Loading…
Cancel
Save