jl777 7 years ago
parent
commit
00b5f918e9
  1. 29
      iguana/exchanges/LP_ordermatch.c

29
iguana/exchanges/LP_ordermatch.c

@ -334,7 +334,7 @@ int32_t LP_arrayfind(cJSON *array,bits256 txid,int32_t vout)
double LP_query(void *ctx,char *myipaddr,int32_t mypubsock,char *method,struct LP_quoteinfo *qp)
{
cJSON *reqjson; bits256 zero; char *msg,*msg2; int32_t i,flag = 0; double price = 0.; struct LP_utxoinfo *utxo;
cJSON *reqjson; bits256 zero; char *msg; int32_t i,flag = 0; double price = 0.; struct LP_utxoinfo *utxo;
if ( strcmp(method,"request") == 0 )
{
if ( (utxo= LP_utxofind(0,qp->desttxid,qp->destvout)) != 0 && LP_ismine(utxo) > 0 && LP_isavailable(utxo) > 0 )
@ -351,22 +351,29 @@ double LP_query(void *ctx,char *myipaddr,int32_t mypubsock,char *method,struct L
jaddbits256(reqjson,"pubkey",qp->srchash);
jaddstr(reqjson,"method",method);
msg = jprint(reqjson,1);
msg2 = clonestr(msg);
printf("QUERY.(%s)\n",msg);
LP_broadcast_message(LP_mypubsock,qp->srccoin,qp->destcoin,qp->srchash,msg);
memset(&zero,0,sizeof(zero));
LP_broadcast_message(LP_mypubsock,qp->srccoin,qp->destcoin,zero,msg2);
for (i=0; i<30; i++)
if ( strcmp(method,"connect") == 0 )
{
if ( (price= LP_pricecache(qp,qp->srccoin,qp->destcoin,qp->txid,qp->vout)) > SMALLVAL )
sleep(3);
memset(&zero,0,sizeof(zero));
LP_broadcast_message(LP_mypubsock,qp->srccoin,qp->destcoin,zero,msg);
}
else
{
memset(&zero,0,sizeof(zero));
LP_broadcast_message(LP_mypubsock,qp->srccoin,qp->destcoin,zero,msg);
for (i=0; i<30; i++)
{
if ( flag == 0 || bits256_nonz(qp->desthash) != 0 )
if ( (price= LP_pricecache(qp,qp->srccoin,qp->destcoin,qp->txid,qp->vout)) > SMALLVAL )
{
printf("break out of loop.%d price %.8f %s/%s\n",i,price,qp->srccoin,qp->destcoin);
break;
if ( flag == 0 || bits256_nonz(qp->desthash) != 0 )
{
printf("break out of loop.%d price %.8f %s/%s\n",i,price,qp->srccoin,qp->destcoin);
break;
}
}
usleep(1000000);
}
usleep(1000000);
}
return(price);
}

Loading…
Cancel
Save