Browse Source

Test

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

8
iguana/exchanges/LP_ordermatch.c

@ -1057,6 +1057,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);
portable_mutex_lock(&LP_tradesmutex);
DL_DELETE(LP_tradesQ,qtp);
HASH_FIND(hh,LP_trades,&qtp->aliceid,sizeof(qtp->aliceid),tp);
@ -1065,9 +1066,10 @@ void LP_tradesloop(void *ctx)
tp = qtp;
HASH_ADD(hh,LP_trades,aliceid,sizeof(tp->aliceid),tp);
portable_mutex_unlock(&LP_tradesmutex);
printf("iambob.%d funcid.%d vs %d\n",tp->iambob,funcid,LP_REQUEST);
if ( tp->iambob != 0 && funcid == LP_REQUEST ) // bob maybe sends LP_RESERVED
{
if ( (qp= LP_trades_gotrequest(ctx,&tp->Qs[LP_REQUEST],&Q,tp->pairstr)) != 0 )
if ( (qp= LP_trades_gotrequest(ctx,&Q,&tp->Qs[LP_REQUEST],tp->pairstr)) != 0 )
tp->Qs[LP_RESERVED] = Q;
}
else if ( tp->iambob == 0 && funcid == LP_RESERVED ) // alice maybe sends LP_CONNECT
@ -1187,6 +1189,7 @@ void LP_tradecommandQ(struct LP_quoteinfo *qp,char *pairstr,int32_t funcid)
safecopy(qtp->pairstr,pairstr,sizeof(qtp->pairstr));
DL_APPEND(LP_tradesQ,qtp);
portable_mutex_unlock(&LP_tradesmutex);
printf("queue.%d %p\n",funcid,qtp);
}
int32_t LP_tradecommand(void *ctx,char *myipaddr,int32_t pubsock,cJSON *argjson,uint8_t *data,int32_t datalen)
@ -1245,7 +1248,7 @@ int32_t LP_tradecommand(void *ctx,char *myipaddr,int32_t pubsock,cJSON *argjson,
price = LP_myprice(&bid,&ask,Q.srccoin,Q.destcoin);
if ( (coin= LP_coinfind(Q.srccoin)) == 0 || price <= SMALLVAL || ask <= SMALLVAL )
{
//printf("this node has no price for %s/%s\n",Q.srccoin,Q.destcoin);
printf("this node has no price for %s/%s\n",Q.srccoin,Q.destcoin);
return(retval);
}
if ( LP_aliceonly(Q.srccoin) > 0 )
@ -1261,6 +1264,7 @@ int32_t LP_tradecommand(void *ctx,char *myipaddr,int32_t pubsock,cJSON *argjson,
}
else if ( strcmp(method,"connect") == 0 )
{
LP_bob_competition(&counter,aliceid,qprice,1000);
if ( Qtrades == 0 )
LP_trades_gotconnect(ctx,&Q,&Q2,jstr(argjson,"pair"));
else LP_tradecommandQ(&Q,jstr(argjson,"pair"),LP_CONNECT);

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