From 746dc87850fdff4128f43147540c20f7dcb41f62 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Nov 2017 17:35:39 +0200 Subject: [PATCH] Test --- iguana/exchanges/LP_nativeDEX.c | 2 +- iguana/exchanges/LP_remember.c | 6 ++++++ iguana/exchanges/LP_swap.c | 9 +++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_nativeDEX.c b/iguana/exchanges/LP_nativeDEX.c index 5b44da252..5c10f50ba 100644 --- a/iguana/exchanges/LP_nativeDEX.c +++ b/iguana/exchanges/LP_nativeDEX.c @@ -96,7 +96,7 @@ struct LP_address_utxo *LP_garbage_collector2; //uint32_t LP_deadman_switch; uint16_t LP_fixed_pairport,LP_publicport; -uint32_t LP_lastnonce,LP_counter; +uint32_t LP_lastnonce,LP_counter,LP_swap_endcritical,LP_swap_critical; int32_t LP_mybussock = -1; int32_t LP_mypubsock = -1; int32_t LP_mypullsock = -1; diff --git a/iguana/exchanges/LP_remember.c b/iguana/exchanges/LP_remember.c index 7889181bf..f5ea3229a 100644 --- a/iguana/exchanges/LP_remember.c +++ b/iguana/exchanges/LP_remember.c @@ -456,6 +456,12 @@ cJSON *LP_swap_json(struct LP_swap_remember *rswap) { cJSON *item,*array; int32_t i; item = cJSON_CreateObject(); + if ( LP_swap_endcritical < LP_swap_critical ) + { + jaddstr(item,"warning","swaps in critical section"); + jaddnum(item,"critical",LP_swap_critical); + jaddnum(item,"endcritical",LP_swap_endcritical); + } jaddnum(item,"expiration",rswap->expiration);// - INSTANTDEX_LOCKTIME*2); jaddnum(item,"tradeid",rswap->tradeid); jaddnum(item,"requestid",rswap->requestid); diff --git a/iguana/exchanges/LP_swap.c b/iguana/exchanges/LP_swap.c index e1c80d505..30329c864 100644 --- a/iguana/exchanges/LP_swap.c +++ b/iguana/exchanges/LP_swap.c @@ -796,6 +796,7 @@ void LP_bobloop(void *_swap) basilisk_bobdeposit_refund(swap,swap->I.putduration); //printf("depositlen.%d\n",swap->bobdeposit.I.datalen); LP_swapsfp_update(&swap->I.req); + LP_swap_critical = (uint32_t)time(NULL); if ( LP_waitfor(swap->N.pair,swap,LP_SWAPSTEP_TIMEOUT*10,LP_verify_otherfee) < 0 ) printf("error waiting for alicefee\n"); else if ( LP_swapdata_rawtxsend(swap->N.pair,swap,0x200,data,maxlen,&swap->bobdeposit,0x100,0) == 0 ) @@ -804,6 +805,7 @@ void LP_bobloop(void *_swap) printf("error waiting for alicepayment\n"); else { + LP_swap_critical = (uint32_t)time(NULL); if ( basilisk_bobscripts_set(swap,0,1) < 0 ) printf("error bobscripts payment\n"); else @@ -813,9 +815,11 @@ void LP_bobloop(void *_swap) else m = swap->I.aliceconfirms; while ( (n= LP_numconfirms(swap->I.alicestr,swap->alicepayment.I.destaddr,swap->alicepayment.I.signedtxid,0,1)) < m ) // sync with alice { + LP_swap_critical = (uint32_t)time(NULL); char str[65];printf("%d wait for alicepayment %s numconfs.%d %s %s\n",n,swap->alicepayment.I.destaddr,m,swap->I.alicestr,bits256_str(str,swap->alicepayment.I.signedtxid)); sleep(10); } + LP_swap_critical = (uint32_t)time(NULL); if ( LP_swapdata_rawtxsend(swap->N.pair,swap,0x8000,data,maxlen,&swap->bobpayment,0x4000,0) == 0 ) printf("error sending bobpayment\n"); //if ( LP_waitfor(swap->N.pair,swap,10,LP_verify_alicespend) < 0 ) @@ -826,6 +830,7 @@ void LP_bobloop(void *_swap) basilisk_bobpayment_reclaim(swap,swap->I.callduration); if ( swap->N.pair >= 0 ) nn_close(swap->N.pair), swap->N.pair = -1; + LP_swap_endcritical = (uint32_t)time(NULL); LP_swapwait(swap->I.req.requestid,swap->I.req.quoteid,LP_atomic_locktime(swap->I.bobstr,swap->I.alicestr)*2,30); } } @@ -857,6 +862,7 @@ void LP_aliceloop(void *_swap) else { LP_swapsfp_update(&swap->I.req); + LP_swap_critical = (uint32_t)time(NULL); if ( LP_swapdata_rawtxsend(swap->N.pair,swap,0x80,data,maxlen,&swap->myfee,0x40,0) == 0 ) printf("error sending alicefee\n"); else if ( LP_waitfor(swap->N.pair,swap,1800,LP_verify_bobdeposit) < 0 ) @@ -870,14 +876,17 @@ void LP_aliceloop(void *_swap) else m = swap->I.aliceconfirms; while ( (n= LP_numconfirms(swap->I.alicestr,swap->alicepayment.I.destaddr,swap->alicepayment.I.signedtxid,0,1)) < m ) { + LP_swap_critical = (uint32_t)time(NULL); char str[65];printf("%d wait for alicepayment %s numconfs.%d %s %s\n",n,swap->alicepayment.I.destaddr,m,swap->I.alicestr,bits256_str(str,swap->alicepayment.I.signedtxid)); sleep(10); } swap->sentflag = 1; + LP_swap_critical = (uint32_t)time(NULL); if ( LP_waitfor(swap->N.pair,swap,1800,LP_verify_bobpayment) < 0 ) printf("error waiting for bobpayment\n"); else { + LP_swap_endcritical = (uint32_t)time(NULL); while ( (n= LP_numconfirms(swap->I.bobstr,swap->bobpayment.I.destaddr,swap->bobpayment.I.signedtxid,0,1)) < swap->I.bobconfirms ) { char str[65];printf("%d wait for bobpayment %s numconfs.%d %s %s\n",n,swap->bobpayment.I.destaddr,swap->I.bobconfirms,swap->I.bobstr,bits256_str(str,swap->bobpayment.I.signedtxid));