From e27eb9008472be9bd4e7c13e984c41a30e381528 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 15 Feb 2018 19:58:45 +0200 Subject: [PATCH] Test --- iguana/exchanges/LP_remember.c | 2 +- iguana/exchanges/LP_swap.c | 17 ++++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/iguana/exchanges/LP_remember.c b/iguana/exchanges/LP_remember.c index ecfeff5f5..32f7c8cec 100644 --- a/iguana/exchanges/LP_remember.c +++ b/iguana/exchanges/LP_remember.c @@ -1282,7 +1282,7 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti free_json(txoutobj), flag = 0; else flag = -1, rswap.depositspent = deadtxid; } - if ( flag == 0 && (bits256_nonz(rswap.Apaymentspent) != 0 || time(NULL) > rswap.dlocktime-777 || (bits256_nonz(rswap.txids[BASILISK_BOBPAYMENT]) == 0 && time(NULL) > rswap.dlocktime-2*INSTANTDEX_LOCKTIME+777)) ) + if ( flag == 0 && (bits256_nonz(rswap.Apaymentspent) != 0 || time(NULL) > rswap.dlocktime-777 || (bits256_nonz(rswap.txids[BASILISK_ALICEPAYMENT]) == 0 && time(NULL) > rswap.dlocktime-2*INSTANTDEX_LOCKTIME+777) || (bits256_nonz(rswap.txids[BASILISK_BOBPAYMENT]) == 0 && time(NULL) > rswap.dlocktime-3*INSTANTDEX_LOCKTIME/2)) ) { //printf("do the refund! paymentspent.%s now.%u vs expiration.%u\n",bits256_str(str,rswap.paymentspent),(uint32_t)time(NULL),rswap.expiration); //if ( txbytes[BASILISK_BOBREFUND] == 0 ) diff --git a/iguana/exchanges/LP_swap.c b/iguana/exchanges/LP_swap.c index 85f6a256f..0486c1b8b 100644 --- a/iguana/exchanges/LP_swap.c +++ b/iguana/exchanges/LP_swap.c @@ -730,8 +730,6 @@ int32_t LP_swapwait(struct basilisk_swap *swap,uint32_t requestid,uint32_t quote 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 < divisor*60 ) - // sleeptime = divisor * 60; while ( time(NULL) < expiration ) { if ( (retstr= basilisk_swapentry(requestid,quoteid,1)) != 0 ) @@ -741,18 +739,18 @@ int32_t LP_swapwait(struct basilisk_swap *swap,uint32_t requestid,uint32_t quote if ( jstr(retjson,"status") != 0 && strcmp(jstr(retjson,"status"),"finished") == 0 ) { swap->I.finished = (uint32_t)time(NULL); + free_json(retjson); + free(retstr); break; } - //else printf("NOT FINISHED.(%s)\n",jprint(retjson,0)); + else if ( time(NULL) > swap->I.expiration ) + printf("NOT FINISHED.(%s)\n",jprint(retjson,0)); free_json(retjson); retjson = 0; } free(retstr); } sleep(sleeptime); - //sleep(sleeptime/divisor); - //if ( divisor > 1 ) - // divisor--; } if ( retjson != 0 ) { @@ -764,7 +762,12 @@ int32_t LP_swapwait(struct basilisk_swap *swap,uint32_t requestid,uint32_t quote free(retstr); } return(0); - } else return(-1); + } + else + { + printf("\nSWAP did not complete! %u-%u %s\n",requestid,quoteid,jprint(retjson,0)); + return(-1); + } } void LP_bobloop(void *_swap)