From 76b05f86e65dda7bb82a3991eaf3fe105b12422f Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 21 Jun 2017 11:05:12 +0300 Subject: [PATCH] Test --- iguana/exchanges/LP_include.h | 6 ++++++ iguana/exchanges/LP_nativeDEX.c | 4 ++-- iguana/exchanges/LP_network.c | 4 ---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/iguana/exchanges/LP_include.h b/iguana/exchanges/LP_include.h index f28054ab2..1e797b2e7 100644 --- a/iguana/exchanges/LP_include.h +++ b/iguana/exchanges/LP_include.h @@ -24,6 +24,12 @@ #define LP_COMMAND_SENDSOCK NN_PUSH #define LP_COMMAND_RECVSOCK NN_PULL + +#define PSOCK_KEEPALIVE 600 +#define MAINLOOP_PERSEC 10 +#define MAX_PSOCK_PORT 60000 +#define MIN_PSOCK_PORT 10000 + #define LP_HTTP_TIMEOUT 3 #define LP_MAXPEER_ERRORS 3 #define LP_SWAPSTEP_TIMEOUT 3 diff --git a/iguana/exchanges/LP_nativeDEX.c b/iguana/exchanges/LP_nativeDEX.c index 0a4aa8d08..1432c4537 100644 --- a/iguana/exchanges/LP_nativeDEX.c +++ b/iguana/exchanges/LP_nativeDEX.c @@ -308,7 +308,7 @@ int32_t LP_mainloop_iter(void *ctx,char *myipaddr,struct LP_peerinfo *mypeer,int if ( IAMLP != 0 && (counter % 600) == 42 ) LP_hellos(); //if ( LP_canbind == 0 ) printf("counter.%d canbind.%d\n",counter,LP_canbind); - if ( LP_canbind == 0 && (counter % 60) == 13 ) + if ( LP_canbind == 0 && (counter % (PSOCK_KEEPALIVE*MAINLOOP_PERSEC/2)) == 13 ) { char keepalive[128]; sprintf(keepalive,"{\"method\":\"keepalive\"}"); @@ -480,7 +480,7 @@ void LPinit(uint16_t myport,uint16_t mypullport,uint16_t mypubport,double profit { //fprintf(stderr,"."); if ( LP_mainloop_iter(ctx,myipaddr,mypeer,pubsock,pushaddr,mypullport,pullsock,myport,passphrase,profitmargin) == 0 ) - usleep(100000); + usleep(1000000 / MAINLOOP_PERSEC); if ( LP_canbind == 0 ) { //printf("check deadman %u vs %u\n",LP_deadman_switch,(uint32_t)time(NULL)); diff --git a/iguana/exchanges/LP_network.c b/iguana/exchanges/LP_network.c index cf95fc9db..b69385cb2 100644 --- a/iguana/exchanges/LP_network.c +++ b/iguana/exchanges/LP_network.c @@ -18,10 +18,6 @@ // marketmaker // -#define PSOCK_KEEPALIVE 600 -#define MAX_PSOCK_PORT 60000 -#define MIN_PSOCK_PORT 10000 - struct psock { uint32_t lasttime,lastping,errors;