From 3cb25a8c237b5dac0f8372f25a347f55c9f8267b Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 14 Nov 2017 23:18:21 +0200 Subject: [PATCH 01/14] Test --- iguana/exchanges/LP_nativeDEX.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/iguana/exchanges/LP_nativeDEX.c b/iguana/exchanges/LP_nativeDEX.c index 64687dedc..4b33908b8 100644 --- a/iguana/exchanges/LP_nativeDEX.c +++ b/iguana/exchanges/LP_nativeDEX.c @@ -17,8 +17,10 @@ // LP_nativeDEX.c // marketmaker // -// single utxo allocations, reject result, latency +// single utxo allocations alice, reject result, latency // alice waiting for bestprice +//if ( G.LP_pendingswaps != 0 ) +//return(-1); // bot safe to exit? // // BCH signing @@ -1054,37 +1056,37 @@ void LPinit(uint16_t myport,uint16_t mypullport,uint16_t mypubport,uint16_t mybu printf("error launching gc_loop for port.%u\n",myport); exit(-1); } - if ( OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)prices_loop,ctx) != 0 ) + if ( 0 && OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)prices_loop,ctx) != 0 ) { printf("error launching prices_loop for port.%u\n",myport); exit(-1); } - if ( OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)LP_coinsloop,(void *)"") != 0 ) + if ( 0 && OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)LP_coinsloop,(void *)"") != 0 ) { printf("error launching LP_coinsloop for port.%u\n",myport); exit(-1); } - if ( OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)LP_coinsloop,(void *)"BTC") != 0 ) + if ( 0 && OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)LP_coinsloop,(void *)"BTC") != 0 ) { printf("error launching BTC LP_coinsloop for port.%u\n",myport); exit(-1); } - if ( OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)LP_coinsloop,(void *)"KMD") != 0 ) + if ( 0 && OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)LP_coinsloop,(void *)"KMD") != 0 ) { printf("error launching KMD LP_coinsloop for port.%u\n",myport); exit(-1); } - if ( OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)LP_pubkeysloop,(void *)myipaddr) != 0 ) + if ( 0 && OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)LP_pubkeysloop,(void *)myipaddr) != 0 ) { printf("error launching LP_pubkeysloop for ctx.%p\n",ctx); exit(-1); } - if ( OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)LP_privkeysloop,(void *)myipaddr) != 0 ) + if ( 0 && OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)LP_privkeysloop,(void *)myipaddr) != 0 ) { printf("error launching LP_privkeysloop for ctx.%p\n",ctx); exit(-1); } - if ( OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)LP_swapsloop,(void *)myipaddr) != 0 ) + if ( 0 && OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)LP_swapsloop,(void *)myipaddr) != 0 ) { printf("error launching LP_swapsloop for port.%u\n",myport); exit(-1); From 8c07a90770936fa667c3250611138b7f5d37ed03 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 14 Nov 2017 23:21:55 +0200 Subject: [PATCH 02/14] Test --- iguana/exchanges/LP_nativeDEX.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/iguana/exchanges/LP_nativeDEX.c b/iguana/exchanges/LP_nativeDEX.c index 4b33908b8..7510f368c 100644 --- a/iguana/exchanges/LP_nativeDEX.c +++ b/iguana/exchanges/LP_nativeDEX.c @@ -1020,7 +1020,7 @@ void LPinit(uint16_t myport,uint16_t mypullport,uint16_t mypubport,uint16_t mybu printf("error launching LP_psockloop for (%s)\n",myipaddr); exit(-1); } - if ( OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)LP_reserved_msgs,(void *)myipaddr) != 0 ) + if ( 0 && OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)LP_reserved_msgs,(void *)myipaddr) != 0 ) { printf("error launching LP_reserved_msgs for (%s)\n",myipaddr); exit(-1); @@ -1030,13 +1030,13 @@ void LPinit(uint16_t myport,uint16_t mypullport,uint16_t mypubport,uint16_t mybu printf("error launching utxosQ_loop for (%s)\n",myipaddr); exit(-1); } - if ( OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)stats_rpcloop,(void *)&myport) != 0 ) + if ( 0 && OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)stats_rpcloop,(void *)&myport) != 0 ) { printf("error launching stats rpcloop for port.%u\n",myport); exit(-1); } uint16_t myport2 = myport-1; - if ( OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)stats_rpcloop,(void *)&myport2) != 0 ) + if ( 0 && OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)stats_rpcloop,(void *)&myport2) != 0 ) { printf("error launching stats rpcloop for port.%u\n",myport); exit(-1); From 823e972eda4df41c9a4a467877ad76feedda2898 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 14 Nov 2017 23:24:13 +0200 Subject: [PATCH 03/14] Test --- iguana/exchanges/LP_nativeDEX.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/iguana/exchanges/LP_nativeDEX.c b/iguana/exchanges/LP_nativeDEX.c index 7510f368c..259053f1a 100644 --- a/iguana/exchanges/LP_nativeDEX.c +++ b/iguana/exchanges/LP_nativeDEX.c @@ -1025,7 +1025,7 @@ void LPinit(uint16_t myport,uint16_t mypullport,uint16_t mypubport,uint16_t mybu printf("error launching LP_reserved_msgs for (%s)\n",myipaddr); exit(-1); } - if ( OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)utxosQ_loop,(void *)myipaddr) != 0 ) + if ( 0 && OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)utxosQ_loop,(void *)myipaddr) != 0 ) { printf("error launching utxosQ_loop for (%s)\n",myipaddr); exit(-1); @@ -1046,12 +1046,12 @@ void LPinit(uint16_t myport,uint16_t mypullport,uint16_t mypubport,uint16_t mybu printf("error launching command_rpcloop for port.%u\n",myport); exit(-1); } - if ( OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)queue_loop,(void *)myipaddr) != 0 ) + if ( 0 && OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)queue_loop,(void *)myipaddr) != 0 ) { printf("error launching queue_loop for port.%u\n",myport); exit(-1); } - if ( OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)gc_loop,(void *)myipaddr) != 0 ) + if ( 0 && OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)gc_loop,(void *)myipaddr) != 0 ) { printf("error launching gc_loop for port.%u\n",myport); exit(-1); From bbd790bf5582e4965de7968aa4164e1371937dff Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 14 Nov 2017 23:25:51 +0200 Subject: [PATCH 04/14] Test --- iguana/exchanges/LP_nativeDEX.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_nativeDEX.c b/iguana/exchanges/LP_nativeDEX.c index 259053f1a..6108a2f87 100644 --- a/iguana/exchanges/LP_nativeDEX.c +++ b/iguana/exchanges/LP_nativeDEX.c @@ -1101,7 +1101,7 @@ void LPinit(uint16_t myport,uint16_t mypullport,uint16_t mypubport,uint16_t mybu //fprintf(stderr,"."); sleep(3); } - if ( LP_mainloop_iter(ctx,myipaddr,mypeer,pubsock,pushaddr,myport) != 0 ) + if ( 0 && LP_mainloop_iter(ctx,myipaddr,mypeer,pubsock,pushaddr,myport) != 0 ) nonz++; if ( nonz == 0 ) usleep(1000); From 17ff863160d9684ab167a69fded6f3444a53084f Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 14 Nov 2017 23:27:11 +0200 Subject: [PATCH 05/14] Test --- iguana/exchanges/LP_nativeDEX.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_nativeDEX.c b/iguana/exchanges/LP_nativeDEX.c index 6108a2f87..431500f4b 100644 --- a/iguana/exchanges/LP_nativeDEX.c +++ b/iguana/exchanges/LP_nativeDEX.c @@ -1041,7 +1041,7 @@ void LPinit(uint16_t myport,uint16_t mypullport,uint16_t mypubport,uint16_t mybu printf("error launching stats rpcloop for port.%u\n",myport); exit(-1); } - if ( OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)command_rpcloop,(void *)myipaddr) != 0 ) + if ( 0 && OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)command_rpcloop,(void *)myipaddr) != 0 ) { printf("error launching command_rpcloop for port.%u\n",myport); exit(-1); From 7df0dbc54070b20302f099b52ba639a9ded2f901 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 14 Nov 2017 23:29:50 +0200 Subject: [PATCH 06/14] Test --- iguana/exchanges/LP_nativeDEX.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/iguana/exchanges/LP_nativeDEX.c b/iguana/exchanges/LP_nativeDEX.c index 431500f4b..3703437f6 100644 --- a/iguana/exchanges/LP_nativeDEX.c +++ b/iguana/exchanges/LP_nativeDEX.c @@ -1020,23 +1020,23 @@ void LPinit(uint16_t myport,uint16_t mypullport,uint16_t mypubport,uint16_t mybu printf("error launching LP_psockloop for (%s)\n",myipaddr); exit(-1); } - if ( 0 && OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)LP_reserved_msgs,(void *)myipaddr) != 0 ) + if ( OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)LP_reserved_msgs,(void *)myipaddr) != 0 ) { printf("error launching LP_reserved_msgs for (%s)\n",myipaddr); exit(-1); } - if ( 0 && OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)utxosQ_loop,(void *)myipaddr) != 0 ) + if ( OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)utxosQ_loop,(void *)myipaddr) != 0 ) { printf("error launching utxosQ_loop for (%s)\n",myipaddr); exit(-1); } - if ( 0 && OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)stats_rpcloop,(void *)&myport) != 0 ) + if ( OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)stats_rpcloop,(void *)&myport) != 0 ) { printf("error launching stats rpcloop for port.%u\n",myport); exit(-1); } uint16_t myport2 = myport-1; - if ( 0 && OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)stats_rpcloop,(void *)&myport2) != 0 ) + if ( OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)stats_rpcloop,(void *)&myport2) != 0 ) { printf("error launching stats rpcloop for port.%u\n",myport); exit(-1); @@ -1046,47 +1046,47 @@ void LPinit(uint16_t myport,uint16_t mypullport,uint16_t mypubport,uint16_t mybu printf("error launching command_rpcloop for port.%u\n",myport); exit(-1); } - if ( 0 && OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)queue_loop,(void *)myipaddr) != 0 ) + if ( OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)queue_loop,(void *)myipaddr) != 0 ) { printf("error launching queue_loop for port.%u\n",myport); exit(-1); } - if ( 0 && OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)gc_loop,(void *)myipaddr) != 0 ) + if ( OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)gc_loop,(void *)myipaddr) != 0 ) { printf("error launching gc_loop for port.%u\n",myport); exit(-1); } - if ( 0 && OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)prices_loop,ctx) != 0 ) + if ( OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)prices_loop,ctx) != 0 ) { printf("error launching prices_loop for port.%u\n",myport); exit(-1); } - if ( 0 && OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)LP_coinsloop,(void *)"") != 0 ) + if ( OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)LP_coinsloop,(void *)"") != 0 ) { printf("error launching LP_coinsloop for port.%u\n",myport); exit(-1); } - if ( 0 && OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)LP_coinsloop,(void *)"BTC") != 0 ) + if ( OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)LP_coinsloop,(void *)"BTC") != 0 ) { printf("error launching BTC LP_coinsloop for port.%u\n",myport); exit(-1); } - if ( 0 && OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)LP_coinsloop,(void *)"KMD") != 0 ) + if ( OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)LP_coinsloop,(void *)"KMD") != 0 ) { printf("error launching KMD LP_coinsloop for port.%u\n",myport); exit(-1); } - if ( 0 && OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)LP_pubkeysloop,(void *)myipaddr) != 0 ) + if ( OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)LP_pubkeysloop,(void *)myipaddr) != 0 ) { printf("error launching LP_pubkeysloop for ctx.%p\n",ctx); exit(-1); } - if ( 0 && OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)LP_privkeysloop,(void *)myipaddr) != 0 ) + if ( OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)LP_privkeysloop,(void *)myipaddr) != 0 ) { printf("error launching LP_privkeysloop for ctx.%p\n",ctx); exit(-1); } - if ( 0 && OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)LP_swapsloop,(void *)myipaddr) != 0 ) + if ( OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)LP_swapsloop,(void *)myipaddr) != 0 ) { printf("error launching LP_swapsloop for port.%u\n",myport); exit(-1); @@ -1101,7 +1101,7 @@ void LPinit(uint16_t myport,uint16_t mypullport,uint16_t mypubport,uint16_t mybu //fprintf(stderr,"."); sleep(3); } - if ( 0 && LP_mainloop_iter(ctx,myipaddr,mypeer,pubsock,pushaddr,myport) != 0 ) + if ( LP_mainloop_iter(ctx,myipaddr,mypeer,pubsock,pushaddr,myport) != 0 ) nonz++; if ( nonz == 0 ) usleep(1000); From 2e867f10f4a15a98d50786902ee68b0cb49e03a0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 14 Nov 2017 23:34:27 +0200 Subject: [PATCH 07/14] 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 3703437f6..7e876b432 100644 --- a/iguana/exchanges/LP_nativeDEX.c +++ b/iguana/exchanges/LP_nativeDEX.c @@ -364,7 +364,7 @@ int32_t LP_sock_check(char *typestr,void *ctx,char *myipaddr,int32_t pubsock,int } else validreq = 1; recvlen -= sizeof(bits256); } - if ( validreq != 0 ) + if ( 0 && validreq != 0 ) { if ( (retstr= LP_process_message(ctx,typestr,myipaddr,pubsock,ptr,recvlen,sock)) != 0 ) free(retstr); @@ -1041,7 +1041,7 @@ void LPinit(uint16_t myport,uint16_t mypullport,uint16_t mypubport,uint16_t mybu printf("error launching stats rpcloop for port.%u\n",myport); exit(-1); } - if ( 0 && OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)command_rpcloop,(void *)myipaddr) != 0 ) + if ( OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)command_rpcloop,(void *)myipaddr) != 0 ) { printf("error launching command_rpcloop for port.%u\n",myport); exit(-1); From c71b1ad57081979b0f5b62d72d3b995f2c84be6f Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 14 Nov 2017 23:37:12 +0200 Subject: [PATCH 08/14] Test --- iguana/exchanges/LP_nativeDEX.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_nativeDEX.c b/iguana/exchanges/LP_nativeDEX.c index 7e876b432..ae1894ea9 100644 --- a/iguana/exchanges/LP_nativeDEX.c +++ b/iguana/exchanges/LP_nativeDEX.c @@ -356,7 +356,7 @@ int32_t LP_sock_check(char *typestr,void *ctx,char *myipaddr,int32_t pubsock,int } } int32_t validreq = 0; - if ( strlen((char *)ptr)+sizeof(bits256) <= recvlen ) + if ( 0 && strlen((char *)ptr)+sizeof(bits256) <= recvlen ) { if ( LP_magic_check(ptr,recvlen,remoteaddr) <= 0 ) { From 40c3173ec20ad82c1e1181362d17a74da469932a Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 14 Nov 2017 23:40:05 +0200 Subject: [PATCH 09/14] Test --- iguana/exchanges/LP_nativeDEX.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/iguana/exchanges/LP_nativeDEX.c b/iguana/exchanges/LP_nativeDEX.c index ae1894ea9..4f82d0c4a 100644 --- a/iguana/exchanges/LP_nativeDEX.c +++ b/iguana/exchanges/LP_nativeDEX.c @@ -338,6 +338,7 @@ int32_t LP_sock_check(char *typestr,void *ctx,char *myipaddr,int32_t pubsock,int pfd.events = NN_POLLIN; if ( nn_poll(&pfd,1,1) != 1 ) break; + ptr = 0; if ( (recvlen= nn_recv(sock,&ptr,NN_MSG,0)) > 0 ) { methodstr[0] = 0; @@ -387,9 +388,9 @@ int32_t LP_sock_check(char *typestr,void *ctx,char *myipaddr,int32_t pubsock,int free(str); } } - if ( ptr != 0 ) - nn_freemsg(ptr), ptr = 0; } + if ( ptr != 0 ) + nn_freemsg(ptr), ptr = 0; } } return(nonz); From 9006c80202870a7eadbfd1bc6a62f45956db5f84 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 14 Nov 2017 23:44:00 +0200 Subject: [PATCH 10/14] Test --- iguana/exchanges/LP_network.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/iguana/exchanges/LP_network.c b/iguana/exchanges/LP_network.c index 4b33a4717..f45f5142d 100644 --- a/iguana/exchanges/LP_network.c +++ b/iguana/exchanges/LP_network.c @@ -574,12 +574,19 @@ void LP_psockloop(void *_ptr) // printouts seem to be needed for forwarding to w else if ( (pfds[n].revents & POLLIN) != 0 ) { printf("publicsock.%d %s has pollin\n",ptr->publicsock,ptr->publicaddr); + buf = 0; if ( (size= nn_recv(ptr->publicsock,&buf,NN_MSG,0)) > 0 ) { ptr->lasttime = now; sendsock = ptr->sendsock; break; } + else if ( buf != 0 ) + { + nn_freemsg(buf); + buf = 0; + size = 0; + } } } n++; @@ -606,12 +613,12 @@ void LP_psockloop(void *_ptr) // printouts seem to be needed for forwarding to w sendsock = ptr->publicsock; break; } - else - { - nn_freemsg(buf); - buf = 0; - size = 0; - } + } + if ( buf != 0 ) + { + nn_freemsg(buf); + buf = 0; + size = 0; } } } From 67a4e5191f995a8e690340b2e2c58f7d7694d080 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 14 Nov 2017 23:45:58 +0200 Subject: [PATCH 11/14] 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 4f82d0c4a..75e236dac 100644 --- a/iguana/exchanges/LP_nativeDEX.c +++ b/iguana/exchanges/LP_nativeDEX.c @@ -357,7 +357,7 @@ int32_t LP_sock_check(char *typestr,void *ctx,char *myipaddr,int32_t pubsock,int } } int32_t validreq = 0; - if ( 0 && strlen((char *)ptr)+sizeof(bits256) <= recvlen ) + if ( strlen((char *)ptr)+sizeof(bits256) <= recvlen ) { if ( LP_magic_check(ptr,recvlen,remoteaddr) <= 0 ) { @@ -365,7 +365,7 @@ int32_t LP_sock_check(char *typestr,void *ctx,char *myipaddr,int32_t pubsock,int } else validreq = 1; recvlen -= sizeof(bits256); } - if ( 0 && validreq != 0 ) + if ( validreq != 0 ) { if ( (retstr= LP_process_message(ctx,typestr,myipaddr,pubsock,ptr,recvlen,sock)) != 0 ) free(retstr); From 3bb38b13bc1e8c259c78d488baef5ee529af625d Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 14 Nov 2017 23:48:07 +0200 Subject: [PATCH 12/14] Test --- iguana/exchanges/LP_nativeDEX.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_nativeDEX.c b/iguana/exchanges/LP_nativeDEX.c index 75e236dac..98f4cc927 100644 --- a/iguana/exchanges/LP_nativeDEX.c +++ b/iguana/exchanges/LP_nativeDEX.c @@ -365,7 +365,7 @@ int32_t LP_sock_check(char *typestr,void *ctx,char *myipaddr,int32_t pubsock,int } else validreq = 1; recvlen -= sizeof(bits256); } - if ( validreq != 0 ) + if ( 0 && validreq != 0 ) { if ( (retstr= LP_process_message(ctx,typestr,myipaddr,pubsock,ptr,recvlen,sock)) != 0 ) free(retstr); From 83a6006d7e5bd687f63e9b3e1521244839dac090 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 14 Nov 2017 23:58:00 +0200 Subject: [PATCH 13/14] Test --- iguana/exchanges/LP_nativeDEX.c | 5 +++-- iguana/exchanges/LP_ordermatch.c | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/iguana/exchanges/LP_nativeDEX.c b/iguana/exchanges/LP_nativeDEX.c index 98f4cc927..c5c34b353 100644 --- a/iguana/exchanges/LP_nativeDEX.c +++ b/iguana/exchanges/LP_nativeDEX.c @@ -315,8 +315,9 @@ char *LP_process_message(void *ctx,char *typestr,char *myipaddr,int32_t pubsock, } //printf("%.3f %s LP_command_process\n",OS_milliseconds()-millis,jstr(argjson,"method")); } - free_json(argjson); } + if ( argjson != 0 ) + free_json(argjson); } } //else printf("DUPLICATE.(%s)\n",(char *)ptr); portable_mutex_unlock(&LP_commandmutex); @@ -365,7 +366,7 @@ int32_t LP_sock_check(char *typestr,void *ctx,char *myipaddr,int32_t pubsock,int } else validreq = 1; recvlen -= sizeof(bits256); } - if ( 0 && validreq != 0 ) + if ( validreq != 0 ) { if ( (retstr= LP_process_message(ctx,typestr,myipaddr,pubsock,ptr,recvlen,sock)) != 0 ) free(retstr); diff --git a/iguana/exchanges/LP_ordermatch.c b/iguana/exchanges/LP_ordermatch.c index a8c061359..0ab6faca0 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -799,7 +799,7 @@ int32_t LP_tradecommand(void *ctx,char *myipaddr,int32_t pubsock,cJSON *argjson, return(retval); } LP_aliceid(Q.tradeid,Q.aliceid,"reserved",0,0); - printf("alice %s received RESERVED.(%s)\n",bits256_str(str,G.LP_mypub25519),jprint(argjson,0)); + //printf("alice %s received RESERVED.(%s)\n",bits256_str(str,G.LP_mypub25519),jprint(argjson,0)); if ( (retstr= LP_quotereceived(argjson)) != 0 ) free(retstr); LP_reserved(ctx,myipaddr,pubsock,&Q); @@ -929,7 +929,9 @@ int32_t LP_tradecommand(void *ctx,char *myipaddr,int32_t pubsock,cJSON *argjson, printf("(%.8f %.8f) quote price %.8f too low vs %.8f for %s/%s %.8f < %.8f\n",bid,ask,qprice,price,Q.srccoin,Q.destcoin,qprice,(ask - 0.00000001) * 0.998); return(retval); } - char str[65],str2[65]; printf("(%s/v%d %s/v%d) TRADECOMMAND.(%s)\n",bits256_str(str,Q.txid),Q.vout,bits256_str(str2,Q.txid2),Q.vout2,jprint(argjson,0)); + char *astr = jprint(argjson,0); + char str[65],str2[65]; printf("(%s/v%d %s/v%d) TRADECOMMAND.(%s)\n",bits256_str(str,Q.txid),Q.vout,bits256_str(str2,Q.txid2),Q.vout2,astr); + free(astr); if ( strcmp(method,"request") == 0 ) // bob needs apayment + fee tx's { if ( LP_allocated(Q.txid,Q.vout) == 0 && LP_allocated(Q.txid2,Q.vout2) == 0 ) From 0eb9fd4328fb9aa2ee4453484f09846ca5f40c3c Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 15 Nov 2017 00:02:11 +0200 Subject: [PATCH 14/14] Test --- iguana/exchanges/LP_transaction.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/iguana/exchanges/LP_transaction.c b/iguana/exchanges/LP_transaction.c index 4d9ee5fe1..4df4b3895 100644 --- a/iguana/exchanges/LP_transaction.c +++ b/iguana/exchanges/LP_transaction.c @@ -1047,13 +1047,13 @@ char *LP_createrawtransaction(cJSON **txobjp,int32_t *numvinsp,struct iguana_inf return(0); } } - if ( bits256_nonz(utxotxid) == 0 ) + //if ( bits256_nonz(utxotxid) == 0 ) { if ( (ap= LP_address_utxo_reset(coin)) == 0 ) return(0); } - else if ( (ap= LP_address(coin,coin->smartaddr)) == 0 ) - return(0); + //else if ( (ap= LP_address(coin,coin->smartaddr)) == 0 ) + // return(0); memset(utxos,0,sizeof(utxos)); if ( (numutxos= LP_address_utxo_ptrs(coin,0,utxos,max,ap,coin->smartaddr)) <= 0 ) {