From 68574e55351a47b0b4744277ef727d5270e62fa8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 21 Feb 2018 13:30:07 +0200 Subject: [PATCH] Pending only to return null if .finished --- iguana/exchanges/LP_remember.c | 2 ++ iguana/exchanges/LP_swap.c | 20 +++++++++++++------- iguana/exchanges/prices/bet | 4 ++-- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/iguana/exchanges/LP_remember.c b/iguana/exchanges/LP_remember.c index f18cdd969..7e517b9c7 100644 --- a/iguana/exchanges/LP_remember.c +++ b/iguana/exchanges/LP_remember.c @@ -983,6 +983,8 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti if ( (retjson= cJSON_Parse(fstr)) != 0 ) { free(fstr); + if ( pendingonly != 0 ) + free_json(retjson), retjson = 0; return(retjson); } free(fstr); diff --git a/iguana/exchanges/LP_swap.c b/iguana/exchanges/LP_swap.c index 98e2425ae..95dba84b4 100644 --- a/iguana/exchanges/LP_swap.c +++ b/iguana/exchanges/LP_swap.c @@ -728,8 +728,11 @@ uint32_t LP_swapdata_rawtxsend(int32_t pairsock,struct basilisk_swap *swap,uint3 int32_t LP_swapwait(struct basilisk_swap *swap,uint32_t requestid,uint32_t quoteid,int32_t duration,int32_t sleeptime) { char *retstr; cJSON *retjson=0; uint32_t expiration = (uint32_t)(time(NULL) + duration); - printf("wait %d:%d for SWAP.(r%u/q%u) to complete\n",duration,sleeptime,requestid,quoteid); - sleep(sleeptime/3); + if ( sleeptime != 0 ) + { + printf("wait %d:%d for SWAP.(r%u/q%u) to complete\n",duration,sleeptime,requestid,quoteid); + sleep(sleeptime/3); + } while ( time(NULL) < expiration ) { if ( (retstr= basilisk_swapentry(requestid,quoteid,1)) != 0 ) @@ -749,22 +752,25 @@ int32_t LP_swapwait(struct basilisk_swap *swap,uint32_t requestid,uint32_t quote } free(retstr); } - sleep(sleeptime); + if ( sleeptime != 0 ) + sleep(sleeptime); + if ( duration < 0 ) + break; } if ( retjson != 0 ) { - printf("\n>>>>>>>>>>>>>>>>>>>>>>>>>\nSWAP completed! %u-%u %s\n",requestid,quoteid,jprint(retjson,0)); free_json(retjson); - if ( 0 && (retstr= basilisk_swapentry(requestid,quoteid,1)) != 0 ) + if ( (retstr= basilisk_swapentry(requestid,quoteid,1)) != 0 ) { - printf("second call.(%s)\n",retstr); + printf("\n>>>>>>>>>>>>>>>>>>>>>>>>>\nSWAP completed! %u-%u %s\n",requestid,quoteid,retstr); free(retstr); } return(0); } else { - printf("\nSWAP did not complete! %u-%u %s\n",requestid,quoteid,jprint(retjson,0)); + if ( time(NULL) > swap->I.expiration ) + printf("\nSWAP did not complete! %u-%u %s\n",requestid,quoteid,jprint(retjson,0)); return(-1); } } diff --git a/iguana/exchanges/prices/bet b/iguana/exchanges/prices/bet index 94cea0420..9f97c5b08 100644 --- a/iguana/exchanges/prices/bet +++ b/iguana/exchanges/prices/bet @@ -1,3 +1,3 @@ coin=BET -price=0.0005 -invprice=2000 +price=0.00075 +invprice=1333.33