From ff808f857a6ab4cd4962f7ff44f6370a002b9538 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 5 Nov 2017 15:28:54 +0200 Subject: [PATCH 1/7] Test --- iguana/exchanges/LP_nativeDEX.c | 4 ++-- iguana/exchanges/LP_transaction.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/iguana/exchanges/LP_nativeDEX.c b/iguana/exchanges/LP_nativeDEX.c index ae96d1aeb..fe8e56c94 100644 --- a/iguana/exchanges/LP_nativeDEX.c +++ b/iguana/exchanges/LP_nativeDEX.c @@ -446,7 +446,7 @@ void command_rpcloop(void *myipaddr) void utxosQ_loop(void *myipaddr) { strcpy(utxosQ_loop_stats.name,"utxosQ_loop"); - utxosQ_loop_stats.threshold = 50.; + utxosQ_loop_stats.threshold = 150.; while ( 1 ) { LP_millistats_update(&utxosQ_loop_stats); @@ -880,7 +880,7 @@ void LP_reserved_msgs(void *ignore) bits256 zero; int32_t flag,nonz; struct nn_pollfd pfd; memset(zero.bytes,0,sizeof(zero)); strcpy(LP_reserved_msgs_stats.name,"LP_reserved_msgs"); - LP_reserved_msgs_stats.threshold = 50.; + LP_reserved_msgs_stats.threshold = 150.; while ( 1 ) { nonz = 0; diff --git a/iguana/exchanges/LP_transaction.c b/iguana/exchanges/LP_transaction.c index 9f0fdfa69..e9f140178 100644 --- a/iguana/exchanges/LP_transaction.c +++ b/iguana/exchanges/LP_transaction.c @@ -648,7 +648,7 @@ char *basilisk_swap_bobtxspend(bits256 *signedtxidp,uint64_t txfee,char *name,ch satoshis = value - 3*txfee/4; printf("reduce satoshis %.8f by txfee %.8f to value %.8f\n",dstr(satoshis),dstr(txfee),dstr(value)); } - else if ( value == satoshis && (double)txfee/value < 0.001 ) + else if ( value == satoshis && (double)txfee/value < 0.1 ) { satoshis = value - txfee; printf("txfee allocation from value %.8f identical to satoshis: %.8f txfee %.8f\n",dstr(value),dstr(satoshis),dstr(txfee)); From 164e7c7ebc3f436d0cb9d6d573a3bc16694e9158 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 5 Nov 2017 15:47:20 +0200 Subject: [PATCH 2/7] Test --- iguana/exchanges/stats.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/iguana/exchanges/stats.c b/iguana/exchanges/stats.c index 4eea97b8e..6ada27290 100644 --- a/iguana/exchanges/stats.c +++ b/iguana/exchanges/stats.c @@ -745,7 +745,7 @@ extern int32_t IAMLP; void stats_rpcloop(void *args) { static uint32_t counter; - uint16_t port; int32_t sock,bindsock=-1; socklen_t clilen; struct sockaddr_in cli_addr; uint32_t ipbits,localhostbits; struct rpcrequest_info *req; + uint16_t port; int32_t retval,sock,bindsock=-1; socklen_t clilen; struct sockaddr_in cli_addr; uint32_t ipbits,localhostbits; struct rpcrequest_info *req; if ( (port= *(uint16_t *)args) == 0 ) port = 7779; RPC_port = port; @@ -780,21 +780,15 @@ void stats_rpcloop(void *args) req = calloc(1,sizeof(*req)); req->sock = sock; req->ipbits = ipbits; - if ( 0 ) + if ( (retval= OS_thread_create(&req->T,NULL,(void *)LP_rpc_processreq,req)) != 0 ) { - //LP_rpc_processreq((void *)&arg64); - //free(arg64ptr); - //closesocket(sock); - } - else if ( OS_thread_create(&req->T,NULL,(void *)LP_rpc_processreq,req) != 0 ) - { - printf("error launching rpc handler on port %d\n",port); - } - /*if ( 0 && IAMLP != 0 && ipbits != localhostbits ) - { - close(bindsock); - bindsock = iguana_socket(1,"0.0.0.0",port); - } //else printf("skip close and rebind\n");*/ + printf("error launching rpc handler on port %d, retval.%d\n",port,retval); + if ( (retval= OS_thread_create(&req->T,NULL,(void *)LP_rpc_processreq,req)) != 0 ) + { + printf("error2 launching rpc handler on port %d, retval.%d\n",port,retval); + LP_rpc_processreq(req); + } + } } } From 42d25e36cdbb5eed4aac51c017cf8fad7dcf297d Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 5 Nov 2017 15:50:42 +0200 Subject: [PATCH 3/7] Test --- iguana/exchanges/stats.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/iguana/exchanges/stats.c b/iguana/exchanges/stats.c index 6ada27290..dc550354b 100644 --- a/iguana/exchanges/stats.c +++ b/iguana/exchanges/stats.c @@ -745,19 +745,11 @@ extern int32_t IAMLP; void stats_rpcloop(void *args) { static uint32_t counter; - uint16_t port; int32_t retval,sock,bindsock=-1; socklen_t clilen; struct sockaddr_in cli_addr; uint32_t ipbits,localhostbits; struct rpcrequest_info *req; + uint16_t port; int32_t retval,sock,bindsock=-1; socklen_t clilen; struct sockaddr_in cli_addr; uint32_t ipbits,localhostbits; struct rpcrequest_info *req,*req2,*rtmp; if ( (port= *(uint16_t *)args) == 0 ) port = 7779; RPC_port = port; localhostbits = (uint32_t)calc_ipbits("127.0.0.1"); - /*while ( (bindsock= iguana_socket(1,"0.0.0.0",port)) < 0 ) - { - //if ( coin->MAXPEERS == 1 ) - // break; - //exit(-1); - sleep(3); - } - printf(">>>>>>>>>> DEX stats 127.0.0.1:%d bind sock.%d DEX stats API enabled <<<<<<<<<\n",port,bindsock);*/ while ( 1 ) { if ( bindsock < 0 ) @@ -783,6 +775,15 @@ void stats_rpcloop(void *args) if ( (retval= OS_thread_create(&req->T,NULL,(void *)LP_rpc_processreq,req)) != 0 ) { printf("error launching rpc handler on port %d, retval.%d\n",port,retval); + close(bindsock); + bindsock = -1; + portable_mutex_lock(&LP_networkmutex); + DL_FOREACH_SAFE(LP_garbage_collector,req2,rtmp) + { + DL_DELETE(LP_garbage_collector,req2); + free(req2); + } + portable_mutex_unlock(&LP_networkmutex); if ( (retval= OS_thread_create(&req->T,NULL,(void *)LP_rpc_processreq,req)) != 0 ) { printf("error2 launching rpc handler on port %d, retval.%d\n",port,retval); From 54c7540e4c4b673c1f39624d23543d1962ad45e6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 5 Nov 2017 17:13:38 +0200 Subject: [PATCH 4/7] Test --- iguana/exchanges/stats.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/iguana/exchanges/stats.c b/iguana/exchanges/stats.c index dc550354b..37514e596 100644 --- a/iguana/exchanges/stats.c +++ b/iguana/exchanges/stats.c @@ -772,6 +772,8 @@ void stats_rpcloop(void *args) req = calloc(1,sizeof(*req)); req->sock = sock; req->ipbits = ipbits; + LP_rpc_processreq(req); +continue; if ( (retval= OS_thread_create(&req->T,NULL,(void *)LP_rpc_processreq,req)) != 0 ) { printf("error launching rpc handler on port %d, retval.%d\n",port,retval); From 9fa58ccdb5d8f60f73c4145cd5fdb2a8dadca772 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 5 Nov 2017 17:38:07 +0200 Subject: [PATCH 5/7] Test --- iguana/exchanges/LP_nativeDEX.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_nativeDEX.c b/iguana/exchanges/LP_nativeDEX.c index fe8e56c94..32a484a39 100644 --- a/iguana/exchanges/LP_nativeDEX.c +++ b/iguana/exchanges/LP_nativeDEX.c @@ -65,7 +65,8 @@ void LP_millistats_update(struct LP_millistats *mp) mp->millisum += elapsed; if ( mp->threshold != 0. && elapsed > mp->threshold ) { - printf("%32s elapsed %10.2f millis > threshold %10.2f, ave %10.2f millis, count.%u\n",mp->name,elapsed,mp->threshold,mp->millisum/mp->count,mp->count); + if ( IAMLP == 0 ) + printf("%32s elapsed %10.2f millis > threshold %10.2f, ave %10.2f millis, count.%u\n",mp->name,elapsed,mp->threshold,mp->millisum/mp->count,mp->count); } mp->lastmilli = millis; } From c6a832c1bad7c7ae8f4fb2c160314d482419ff47 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 5 Nov 2017 17:50:12 +0200 Subject: [PATCH 6/7] Test --- iguana/exchanges/LP_nativeDEX.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iguana/exchanges/LP_nativeDEX.c b/iguana/exchanges/LP_nativeDEX.c index 32a484a39..907f790c0 100644 --- a/iguana/exchanges/LP_nativeDEX.c +++ b/iguana/exchanges/LP_nativeDEX.c @@ -724,9 +724,9 @@ int32_t LP_mainloop_iter(void *ctx,char *myipaddr,struct LP_peerinfo *mypeer,int } HASH_ITER(hh,LP_coins,coin,ctmp) // firstrefht,firstscanht,lastscanht { - if ( coin->addr_listunspent_requested != 0 && time(NULL) > coin->lastpushtime+LP_ORDERBOOK_DURATION ) + if ( coin->addr_listunspent_requested != 0 && time(NULL) > coin->lastpushtime+10 ) { - //printf("PUSH addr_listunspent_requested %u\n",coin->addr_listunspent_requested); + printf("PUSH addr_listunspent_requested %u\n",coin->addr_listunspent_requested); coin->lastpushtime = (uint32_t)time(NULL); LP_smartutxos_push(coin); coin->addr_listunspent_requested = 0; From 5470b73651aca09cb9bbb594c9a9dba957ffa8eb Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 5 Nov 2017 18:02:10 +0200 Subject: [PATCH 7/7] Test --- iguana/exchanges/LP_commands.c | 8 +++++++- iguana/exchanges/LP_nativeDEX.c | 6 +++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/iguana/exchanges/LP_commands.c b/iguana/exchanges/LP_commands.c index 831675653..6a80ff7ed 100644 --- a/iguana/exchanges/LP_commands.c +++ b/iguana/exchanges/LP_commands.c @@ -342,9 +342,15 @@ bot_resume(botid)\n\ if ( LP_conflicts_find(ptr) == 0 ) { ptr->inactive = 0; - cJSON *array = cJSON_CreateArray(); + cJSON *array; if ( ptr->smartaddr[0] != 0 ) LP_unspents_load(coin,ptr->smartaddr); + if ( LP_getheight(ptr) <= 0 ) + { + ptr->inactive = (uint32_t)time(NULL); + return(clonestr("{\"error\":\"coin cant be activated till synced\"}")); + } else LP_unspents_load(coin,ptr->smartaddr); + array = cJSON_CreateArray(); jaddi(array,LP_coinjson(ptr,0)); return(jprint(array,1)); } else return(clonestr("{\"error\":\"coin port conflicts with existing coin\"}")); diff --git a/iguana/exchanges/LP_nativeDEX.c b/iguana/exchanges/LP_nativeDEX.c index 907f790c0..09cb57a93 100644 --- a/iguana/exchanges/LP_nativeDEX.c +++ b/iguana/exchanges/LP_nativeDEX.c @@ -726,7 +726,7 @@ int32_t LP_mainloop_iter(void *ctx,char *myipaddr,struct LP_peerinfo *mypeer,int { if ( coin->addr_listunspent_requested != 0 && time(NULL) > coin->lastpushtime+10 ) { - printf("PUSH addr_listunspent_requested %u\n",coin->addr_listunspent_requested); + //printf("PUSH addr_listunspent_requested %u\n",coin->addr_listunspent_requested); coin->lastpushtime = (uint32_t)time(NULL); LP_smartutxos_push(coin); coin->addr_listunspent_requested = 0; @@ -759,7 +759,7 @@ void LP_initcoins(void *ctx,int32_t pubsock,cJSON *coins) { if ( LP_getheight(coin) <= 0 ) coin->inactive = (uint32_t)time(NULL); - LP_unspents_load(coin->symbol,coin->smartaddr); + else LP_unspents_load(coin->symbol,coin->smartaddr); } } if ( (n= cJSON_GetArraySize(coins)) > 0 ) @@ -776,7 +776,7 @@ void LP_initcoins(void *ctx,int32_t pubsock,cJSON *coins) { if ( LP_getheight(coin) <= 0 ) coin->inactive = (uint32_t)time(NULL); - LP_unspents_load(coin->symbol,coin->smartaddr); + else LP_unspents_load(coin->symbol,coin->smartaddr); } } }