Browse Source

Test

etomic
jl777 7 years ago
parent
commit
05d79003d2
  1. 1
      iguana/exchanges/LP_commands.c
  2. 9
      iguana/exchanges/LP_ordermatch.c
  3. 21
      iguana/exchanges/LP_remember.c

1
iguana/exchanges/LP_commands.c

@ -132,6 +132,7 @@ electrum(coin, ipaddr, port)*\n\
snapshot(coin, height)\n\
snapshot_balance(coin, height, addresses[])\n\
dividends(coin, height, <args>)\n\
stop()\n\
\"}"));
//sell(base, rel, price, basevolume, timeout=10, duration=3600)\n\

9
iguana/exchanges/LP_ordermatch.c

@ -776,7 +776,8 @@ char *LP_bestfit(char *rel,double relvolume)
}
struct LP_quoteinfo LP_Alicequery;
double LP_Alicemaxprice; int32_t Alice_timeout;
double LP_Alicemaxprice;
uint32_t Alice_expiration;
char *LP_trade(void *ctx,char *myipaddr,int32_t mypubsock,struct LP_quoteinfo *qp,double maxprice,int32_t timeout,int32_t duration)
{
struct LP_utxoinfo *aliceutxo; double price; //cJSON *bestitem=0; int32_t DEXselector=0; uint32_t expiration; double price; struct LP_pubkeyinfo *pubp; struct basilisk_swap *swap;
@ -787,7 +788,7 @@ char *LP_trade(void *ctx,char *myipaddr,int32_t mypubsock,struct LP_quoteinfo *q
}
price = 0.;
LP_query(ctx,myipaddr,mypubsock,"request",qp);
LP_Alicequery = *qp, LP_Alicemaxprice = maxprice, Alice_timeout = timeout;
LP_Alicequery = *qp, LP_Alicemaxprice = maxprice, Alice_expiration = qp->timestamp + timeout;
return(clonestr("{\"result\":\"success\"}"));
}
@ -801,12 +802,12 @@ int32_t LP_quotecmp(struct LP_quoteinfo *qp,struct LP_quoteinfo *qp2)
void LP_reserved(void *ctx,char *myipaddr,int32_t mypubsock,struct LP_quoteinfo *qp)
{
double price,maxprice = LP_Alicemaxprice;
if ( 0 && time(NULL) > qp->timestamp+Alice_timeout )
if ( time(NULL) > Alice_expiration )
{
printf("time expired for Alice_request\n");
memset(&LP_Alicequery,0,sizeof(LP_Alicequery));
LP_Alicemaxprice = 0.;
Alice_timeout = 0;
Alice_expiration = 0;
}
else if ( LP_quotecmp(qp,&LP_Alicequery) == 0 )
{

21
iguana/exchanges/LP_remember.c

@ -1219,9 +1219,12 @@ void LP_tradecommand_log(cJSON *argjson)
}
}
extern struct LP_quoteinfo LP_Alicequery;
extern uint32_t Alice_expiration;
char *LP_recent_swaps(int32_t limit)
{
char fname[512]; long fsize,offset; FILE *fp; int32_t i=0; uint32_t requestid,quoteid; cJSON *array,*item;
char fname[512]; long fsize,offset; FILE *fp; int32_t i=0; uint32_t requestid,quoteid; cJSON *array,*item,*retjson;
if ( limit <= 0 )
limit = 3;
sprintf(fname,"%s/SWAPS/list",GLOBAL_DBDIR), OS_compatible_path(fname);
@ -1249,5 +1252,19 @@ char *LP_recent_swaps(int32_t limit)
}
fclose(fp);
}
return(jprint(array,1));
retjson = cJSON_CreateObject();
jaddstr(retjson,"result","success");
jadd(retjson,"swaps",array);
if ( time(NULL) < Alice_expiration )
{
item = cJSON_CreateObject();
jaddnum(item,"expiration",Alice_expiration);
jaddnum(item,"timeleft",Alice_expiration-time(NULL));
jaddstr(item,"base",LP_Alicequery.srccoin);
jaddnum(item,"basevalue",dstr(LP_Alicequery.satoshis));
jaddstr(item,"rel",LP_Alicequery.destcoin);
jaddnum(item,"relvalue",dstr(LP_Alicequery.destsatoshis));
jadd(retjson,"pending",item);
} else Alice_expiration = 0;
return(jprint(retjson,1));
}

Loading…
Cancel
Save