Browse Source

Test

etomic
jl777 7 years ago
parent
commit
939a6d86fc
  1. 13
      iguana/exchanges/LP_ordermatch.c
  2. 2
      iguana/exchanges/LP_prices.c

13
iguana/exchanges/LP_ordermatch.c

@ -514,13 +514,7 @@ int32_t LP_connectstartbob(void *ctx,int32_t pubsock,char *base,char *rel,double
char *LP_trade(void *ctx,char *myipaddr,int32_t mypubsock,struct LP_quoteinfo *qp,double maxprice,int32_t timeout,int32_t duration,uint32_t tradeid,bits256 destpubkey)
{
//struct LP_utxoinfo *aliceutxo;
double price;
/*if ( (aliceutxo= LP_utxopairfind(0,qp->desttxid,qp->destvout,qp->feetxid,qp->feevout)) == 0 )
{
char str[65],str2[65]; printf("dest.(%s)/v%d fee.(%s)/v%d\n",bits256_str(str,qp->desttxid),qp->destvout,bits256_str(str2,qp->feetxid),qp->feevout);
return(clonestr("{\"error\":\"cant find alice utxopair\"}"));
}*/
double price; int32_t changed;
price = 0.;
memset(qp->txid.bytes,0,sizeof(qp->txid));
qp->txid2 = qp->txid;
@ -529,6 +523,7 @@ char *LP_trade(void *ctx,char *myipaddr,int32_t mypubsock,struct LP_quoteinfo *q
qp->tradeid = LP_rand();
LP_query(ctx,myipaddr,mypubsock,"request",qp);
LP_Alicequery = *qp, LP_Alicemaxprice = maxprice, Alice_expiration = qp->timestamp + timeout, LP_Alicedestpubkey = destpubkey;
LP_mypriceset(&changed,qp->destcoin,qp->srccoin,1. / maxprice);
char str[65]; printf("LP_trade %s/%s %.8f vol %.8f dest.(%s) maxprice %.8f\n",qp->srccoin,qp->destcoin,dstr(qp->satoshis),dstr(qp->destsatoshis),bits256_str(str,LP_Alicedestpubkey),maxprice);
return(LP_recent_swaps(0));
}
@ -837,7 +832,7 @@ double LP_trades_bobprice(double *bidp,double *askp,struct LP_quoteinfo *qp)
return(0.);
}
price = *askp;
printf("MYPRICE %s/%s %.8f vs qprice %.8f\n",qp->srccoin,qp->destcoin,price,(double)qp->destsatoshis/qp->satoshis);
//printf("MYPRICE %s/%s %.8f vs qprice %.8f\n",qp->srccoin,qp->destcoin,price,(double)qp->destsatoshis/qp->satoshis);
if ( LP_validSPV(qp->destcoin,qp->destaddr,qp->desttxid,qp->destvout) < 0 )
{
printf("%s dest %s failed SPV check\n",qp->destcoin,bits256_str(str,qp->desttxid));
@ -1056,7 +1051,7 @@ void LP_tradesloop(void *ctx)
now = (uint32_t)time(NULL);
Q = qtp->Q;
funcid = qtp->funcid;
//printf("dequeue %p funcid.%d aliceid.%llu iambob.%d\n",qtp,funcid,(long long)qtp->aliceid,qtp->iambob);
printf("dequeue %p funcid.%d aliceid.%llu iambob.%d\n",qtp,funcid,(long long)qtp->aliceid,qtp->iambob);
portable_mutex_lock(&LP_tradesmutex);
DL_DELETE(LP_tradesQ,qtp);
HASH_FIND(hh,LP_trades,&qtp->aliceid,sizeof(qtp->aliceid),tp);

2
iguana/exchanges/LP_prices.c

@ -576,7 +576,7 @@ int32_t LP_mypriceset(int32_t *changedp,char *base,char *rel,double price)
if ( fabs(basepp->myprices[relpp->ind] - price)/price > 0.001 )
*changedp = 1;
basepp->myprices[relpp->ind] = price; // ask
//printf("LP_mypriceset base.%s rel.%s <- price %.8f\n",base,rel,price);
printf("LP_mypriceset base.%s rel.%s <- price %.8f\n",base,rel,price);
//relpp->myprices[basepp->ind] = (1. / price); // bid
if ( (pubp= LP_pubkeyadd(G.LP_mypub25519)) != 0 )
{

Loading…
Cancel
Save