From 7f3723c894b36a5fa548ab6b8c6175e83d012914 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 4 Nov 2017 01:36:58 +0200 Subject: [PATCH 1/8] Test --- iguana/exchanges/LP_rpc.c | 4 +++- iguana/exchanges/LP_socket.c | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_rpc.c b/iguana/exchanges/LP_rpc.c index 2bdb4f807..15175e95f 100644 --- a/iguana/exchanges/LP_rpc.c +++ b/iguana/exchanges/LP_rpc.c @@ -111,7 +111,7 @@ char *LP_apicall(struct iguana_info *coin,char *method,char *params) { if ( (retjson= electrum_submit(coin->symbol,coin->electrum,&retjson,method,params,ELECTRUM_TIMEOUT)) != 0 ) { - retstr = jprint(retjson,0); + retstr = jprint(retjson,1); //printf("got.%p (%s)\n",retjson,retstr); return(retstr); } return(clonestr("{\"error\":\"electrum no response\"}")); @@ -808,6 +808,8 @@ double _LP_getestimatedrate(struct iguana_info *coin) sprintf(buf,"[%d]",strcmp(coin->symbol,"BTC") == 0 ? 6 : 2); if ( (retstr= LP_apicall(coin,coin->electrum==0?"estimatefee" : "blockchain.estimatefee",buf)) != 0 ) { + if ( coin->electrum != 0 ) + printf("estimatefee.(%s)\n",retstr); if ( retstr[0] == '{' && (errjson= cJSON_Parse(retstr)) != 0 ) { if ( jobj(errjson,"error") != 0 ) diff --git a/iguana/exchanges/LP_socket.c b/iguana/exchanges/LP_socket.c index 16da1a0c3..8907be909 100644 --- a/iguana/exchanges/LP_socket.c +++ b/iguana/exchanges/LP_socket.c @@ -592,6 +592,7 @@ cJSON *electrum_addpeer(char *symbol,struct electrum_info *ep,cJSON **retjsonp,c cJSON *electrum_sendrawtransaction(char *symbol,struct electrum_info *ep,cJSON **retjsonp,char *rawtx) { return(electrum_strarg(symbol,ep,retjsonp,"blockchain.transaction.broadcast",rawtx,ELECTRUM_TIMEOUT)); } cJSON *electrum_estimatefee(char *symbol,struct electrum_info *ep,cJSON **retjsonp,int32_t numblocks) { return(electrum_intarg(symbol,ep,retjsonp,"blockchain.estimatefee",numblocks,ELECTRUM_TIMEOUT)); } + cJSON *electrum_getchunk(char *symbol,struct electrum_info *ep,cJSON **retjsonp,int32_t n) { return(electrum_intarg(symbol,ep,retjsonp,"blockchain.block.get_chunk",n,ELECTRUM_TIMEOUT)); } cJSON *electrum_getheader(char *symbol,struct electrum_info *ep,cJSON **retjsonp,int32_t n) From 66945feec7572f438a7b7fe951a52fe863fd4e8d Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 4 Nov 2017 01:39:02 +0200 Subject: [PATCH 2/8] Test --- iguana/exchanges/stats.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/exchanges/stats.c b/iguana/exchanges/stats.c index 09f54d8c7..c75bee6f2 100644 --- a/iguana/exchanges/stats.c +++ b/iguana/exchanges/stats.c @@ -219,7 +219,7 @@ int32_t iguana_socket(int32_t bindflag,char *hostname,uint16_t port) return(-1); } } - if ( listen(sock,512) != 0 ) + if ( listen(sock,1) != 0 ) { printf("listen(%s) port.%d failed: %s sock.%d. errno.%d\n",hostname,port,strerror(errno),sock,errno); if ( sock >= 0 ) From 714bfc992c03a01e9a1d63a1389a343e3f2261a1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 4 Nov 2017 01:46:55 +0200 Subject: [PATCH 3/8] Test --- iguana/exchanges/stats.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/iguana/exchanges/stats.c b/iguana/exchanges/stats.c index c75bee6f2..979ed57da 100644 --- a/iguana/exchanges/stats.c +++ b/iguana/exchanges/stats.c @@ -733,10 +733,11 @@ void LP_rpc_processreq(void *_ptr) 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; uint64_t arg64; void *arg64ptr; + uint16_t port; int32_t sock,bindsock=-1; socklen_t clilen; struct sockaddr_in cli_addr; uint32_t ipbits,localhostbits; uint64_t arg64; void *arg64ptr; if ( (port= *(uint16_t *)args) == 0 ) port = 7779; RPC_port = port; + localhostbits = calc_ipbits("127.0.0.1"); /*while ( (bindsock= iguana_socket(1,"0.0.0.0",port)) < 0 ) { //if ( coin->MAXPEERS == 1 ) @@ -771,18 +772,18 @@ void stats_rpcloop(void *args) { LP_rpc_processreq((void *)&arg64); free(arg64ptr); - //char remoteaddr[64]; - //expand_ipbits(remoteaddr,ipbits); - //printf("finished RPC request from (%s) %x\n",remoteaddr,ipbits); + closesocket(sock); } else if ( OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)LP_rpc_processreq,arg64ptr) != 0 ) { printf("error launching rpc handler on port %d\n",port); // yes, small leak per command } - close(bindsock); - closesocket(sock); - bindsock = iguana_socket(1,"0.0.0.0",port); + if ( ipbits != localhostbits ) + { + close(bindsock); + bindsock = iguana_socket(1,"0.0.0.0",port); + } else printf("skip close and rebind\n"); } } From e9195392925764f4ed382e33c4fa20b1b89d8934 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 4 Nov 2017 01:47:37 +0200 Subject: [PATCH 4/8] Test --- iguana/exchanges/stats.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iguana/exchanges/stats.c b/iguana/exchanges/stats.c index 979ed57da..7351c6f5a 100644 --- a/iguana/exchanges/stats.c +++ b/iguana/exchanges/stats.c @@ -737,7 +737,7 @@ void stats_rpcloop(void *args) if ( (port= *(uint16_t *)args) == 0 ) port = 7779; RPC_port = port; - localhostbits = calc_ipbits("127.0.0.1"); + localhostbits = (uint32_t)calc_ipbits("127.0.0.1"); /*while ( (bindsock= iguana_socket(1,"0.0.0.0",port)) < 0 ) { //if ( coin->MAXPEERS == 1 ) @@ -783,7 +783,7 @@ void stats_rpcloop(void *args) { close(bindsock); bindsock = iguana_socket(1,"0.0.0.0",port); - } else printf("skip close and rebind\n"); + } //else printf("skip close and rebind\n"); } } From d4a6e190dd838b1c7a6ee768a01f319d9e952659 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 4 Nov 2017 01:54:21 +0200 Subject: [PATCH 5/8] Test --- iguana/exchanges/LP_rpc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_rpc.c b/iguana/exchanges/LP_rpc.c index 15175e95f..eb9abe808 100644 --- a/iguana/exchanges/LP_rpc.c +++ b/iguana/exchanges/LP_rpc.c @@ -830,7 +830,7 @@ double _LP_getestimatedrate(struct iguana_info *coin) coin->ratetime = (uint32_t)time(NULL); } free(retstr); - } + } else rate = coin->rate; } else rate = coin->rate; return(rate); } From 22ae89f43781ef5a87de374f7a3208d8d67dd5f6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 4 Nov 2017 06:09:34 +0200 Subject: [PATCH 6/8] Test --- iguana/exchanges/stats.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/exchanges/stats.c b/iguana/exchanges/stats.c index 7351c6f5a..27b44c8c1 100644 --- a/iguana/exchanges/stats.c +++ b/iguana/exchanges/stats.c @@ -779,7 +779,7 @@ void stats_rpcloop(void *args) printf("error launching rpc handler on port %d\n",port); // yes, small leak per command } - if ( ipbits != localhostbits ) + ///if ( ipbits != localhostbits ) { close(bindsock); bindsock = iguana_socket(1,"0.0.0.0",port); From b81df95c222402044899e8d79e10f95b2daf9499 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 4 Nov 2017 06:39:53 +0200 Subject: [PATCH 7/8] Test --- iguana/exchanges/stats.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/exchanges/stats.c b/iguana/exchanges/stats.c index 27b44c8c1..7351c6f5a 100644 --- a/iguana/exchanges/stats.c +++ b/iguana/exchanges/stats.c @@ -779,7 +779,7 @@ void stats_rpcloop(void *args) printf("error launching rpc handler on port %d\n",port); // yes, small leak per command } - ///if ( ipbits != localhostbits ) + if ( ipbits != localhostbits ) { close(bindsock); bindsock = iguana_socket(1,"0.0.0.0",port); From 68173f049dd1d84ec787b839b269dc5259b708eb Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 4 Nov 2017 14:30:19 +0200 Subject: [PATCH 8/8] Test --- iguana/exchanges/stats.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/iguana/exchanges/stats.c b/iguana/exchanges/stats.c index 7351c6f5a..65e2f4208 100644 --- a/iguana/exchanges/stats.c +++ b/iguana/exchanges/stats.c @@ -730,6 +730,7 @@ void LP_rpc_processreq(void *_ptr) free(jsonbuf); } +extern int32_t IAMLP; void stats_rpcloop(void *args) { static uint32_t counter; @@ -779,7 +780,7 @@ void stats_rpcloop(void *args) printf("error launching rpc handler on port %d\n",port); // yes, small leak per command } - if ( ipbits != localhostbits ) + if ( IAMLP != 0 && ipbits != localhostbits ) { close(bindsock); bindsock = iguana_socket(1,"0.0.0.0",port);