jl777 7 years ago
parent
commit
e27eb90084
  1. 2
      iguana/exchanges/LP_remember.c
  2. 17
      iguana/exchanges/LP_swap.c

2
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; free_json(txoutobj), flag = 0;
else flag = -1, rswap.depositspent = deadtxid; 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); //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 ) //if ( txbytes[BASILISK_BOBREFUND] == 0 )

17
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); 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); printf("wait %d:%d for SWAP.(r%u/q%u) to complete\n",duration,sleeptime,requestid,quoteid);
sleep(sleeptime/3); sleep(sleeptime/3);
//if ( sleeptime < divisor*60 )
// sleeptime = divisor * 60;
while ( time(NULL) < expiration ) while ( time(NULL) < expiration )
{ {
if ( (retstr= basilisk_swapentry(requestid,quoteid,1)) != 0 ) 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 ) if ( jstr(retjson,"status") != 0 && strcmp(jstr(retjson,"status"),"finished") == 0 )
{ {
swap->I.finished = (uint32_t)time(NULL); swap->I.finished = (uint32_t)time(NULL);
free_json(retjson);
free(retstr);
break; 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); free_json(retjson);
retjson = 0; retjson = 0;
} }
free(retstr); free(retstr);
} }
sleep(sleeptime); sleep(sleeptime);
//sleep(sleeptime/divisor);
//if ( divisor > 1 )
// divisor--;
} }
if ( retjson != 0 ) if ( retjson != 0 )
{ {
@ -764,7 +762,12 @@ int32_t LP_swapwait(struct basilisk_swap *swap,uint32_t requestid,uint32_t quote
free(retstr); free(retstr);
} }
return(0); 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) void LP_bobloop(void *_swap)

Loading…
Cancel
Save