From b67b99afb3d514970c5366296bac24f9fc840044 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 24 Nov 2017 00:46:05 +0400 Subject: [PATCH] Test --- iguana/exchanges/LP_ordermatch.c | 11 ++++++----- iguana/exchanges/LP_signatures.c | 13 ++++++++----- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/iguana/exchanges/LP_ordermatch.c b/iguana/exchanges/LP_ordermatch.c index c375c07f2..4c4729e51 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -493,10 +493,10 @@ int32_t LP_connectstartbob(void *ctx,int32_t pubsock,cJSON *argjson,char *base,c jaddstr(retjson,"pair",pairstr); char str[65]; printf("BOB pubsock.%d binds to %d (%s)\n",pubsock,pair,bits256_str(str,qp->desthash)); LP_reserved_msg(1,base,rel,qp->desthash,jprint(retjson,0)); - sleep(1); bits256 zero; memset(zero.bytes,0,sizeof(zero)); LP_reserved_msg(1,base,rel,zero,jprint(retjson,0)); + LP_reserved_msg(0,base,rel,zero,jprint(retjson,0)); free_json(retjson); retval = 0; } else printf("error launching swaploop\n"); @@ -998,14 +998,15 @@ int32_t LP_tradecommand(void *ctx,char *myipaddr,int32_t pubsock,cJSON *argjson, jaddnum(retjson,"pending",Q.timestamp + LP_RESERVETIME); //jaddbits256(retjson,"desthash",Q.desthash); jaddstr(retjson,"method","reserved"); - msg = jprint(retjson,0); + msg = jprint(retjson,1); printf("return after queued RESERVED: set swappending.%u accept qprice %.8f, min %.8f\n(%s)\n",Q.timestamp + LP_RESERVETIME,qprice,ask,msg); LP_reserved_msg(1,Q.srccoin,Q.destcoin,Q.desthash,clonestr(msg)); - sleep(1); + //sleep(1); bits256 zero; memset(zero.bytes,0,sizeof(zero)); - LP_reserved_msg(1,Q.srccoin,Q.destcoin,zero,msg); - free_json(retjson); + LP_reserved_msg(1,Q.srccoin,Q.destcoin,zero,clonestr(msg)); + LP_reserved_msg(0,Q.srccoin,Q.destcoin,zero,clonestr(msg)); + free(msg); butxo->T.lasttime = (uint32_t)time(NULL); return(retval); } else printf("request processing selected ineligible utxos?\n"); diff --git a/iguana/exchanges/LP_signatures.c b/iguana/exchanges/LP_signatures.c index 9e7ed2d1e..dc8e1b6ed 100644 --- a/iguana/exchanges/LP_signatures.c +++ b/iguana/exchanges/LP_signatures.c @@ -695,7 +695,7 @@ void LP_listunspent_query(char *symbol,char *coinaddr) void LP_query(void *ctx,char *myipaddr,int32_t mypubsock,char *method,struct LP_quoteinfo *qp) { - cJSON *reqjson; bits256 zero; char *msg,*msg2; int32_t flag = 0; + cJSON *reqjson; bits256 zero; char *msg; int32_t flag = 0; if ( strcmp(method,"request") == 0 ) { if ( LP_allocated(qp->desttxid,qp->destvout) == 0 && LP_allocated(qp->feetxid,qp->feevout) == 0 ) @@ -717,17 +717,20 @@ void LP_query(void *ctx,char *myipaddr,int32_t mypubsock,char *method,struct LP_ if ( jobj(reqjson,"timestamp") == 0 ) jaddnum(reqjson,"timestamp",time(NULL)); msg = jprint(reqjson,1); - msg2 = clonestr(msg); printf("QUERY.(%s)\n",msg); if ( bits256_nonz(qp->srchash) == 0 || strcmp(method,"request") != 0 ) { memset(&zero,0,sizeof(zero)); - portable_mutex_lock(&LP_reservedmutex); + LP_reserved_msg(1,qp->srccoin,qp->destcoin,qp->desthash,clonestr(msg)); + LP_reserved_msg(1,qp->srccoin,qp->destcoin,zero,clonestr(msg)); + LP_reserved_msg(0,qp->srccoin,qp->destcoin,zero,clonestr(msg)); + free(msg); + /*portable_mutex_lock(&LP_reservedmutex); if ( num_Reserved_msgs[1] < sizeof(Reserved_msgs[1])/sizeof(*Reserved_msgs[1])-2 ) Reserved_msgs[1][num_Reserved_msgs[1]++] = msg; if ( num_Reserved_msgs[0] < sizeof(Reserved_msgs[0])/sizeof(*Reserved_msgs[0])-2 ) Reserved_msgs[0][num_Reserved_msgs[0]++] = msg2; - portable_mutex_unlock(&LP_reservedmutex); - } else LP_broadcast_message(LP_mypubsock,qp->srccoin,qp->destcoin,qp->srchash,msg2); + portable_mutex_unlock(&LP_reservedmutex);*/ + } else LP_broadcast_message(LP_mypubsock,qp->srccoin,qp->destcoin,qp->srchash,msg); }