Post
Topic
Board Announcements (Altcoins)
Re: [ANN][GAP] Gapcoin - Prime Gap Search - New Math Algo - CPU / GPU - Zero Premine
by
bsunau7
on 08/11/2014, 09:34:20 UTC
Hi Guys,

Here is a little fix which increased my block count (got your attention)?

Added TCP keep alives with a sub 5 minute period to the wallet.  Three lines of code in net.cpp and netbase.cpp and a tweak of the Linux kernel.

net.cpp diff:

Code:
--- net.cpp_orig        2014-11-07 19:38:26.941369345 +0100
+++ net.cpp     2014-11-07 19:42:11.077371850 +0100
@@ -1594,6 +1594,7 @@
     // Different way of disabling SIGPIPE on BSD
     setsockopt(hListenSocket, SOL_SOCKET, SO_NOSIGPIPE, (void*)&nOne, sizeof(int));
 #endif
+    setsockopt(hListenSocket, SOL_SOCKET, SO_KEEPALIVE, (void*)&nOne, sizeof(int));

 #ifndef WIN32
     // Allow binding if the port is still in TIME_WAIT state after


netbase.cp diff:

Code:
--- netbase.cpp_orig    2014-11-07 19:38:21.365369283 +0100
+++ netbase.cpp 2014-11-07 19:41:02.549371084 +0100
@@ -329,6 +329,8 @@
     int set = 1;
     setsockopt(hSocket, SOL_SOCKET, SO_NOSIGPIPE, (void*)&set, sizeof(int));
 #endif
+    int set = 1;
+    setsockopt(hSocket, SOL_SOCKET, SO_KEEPALIVE, (void*)&set, sizeof(int));

 #ifdef WIN32
     u_long fNonblock = 1;

Add into /etc/sysctl.conf

Code:
net.ipv4.tcp_keepalive_time = 240
net.ipv4.tcp_keepalive_intvl = 15
net.ipv4.tcp_keepalive_probes = 9

Then "sysctl -p /etc/sysctl.conf" to make it take effect.

I went from spending half my time in 45 minute limbo land mining dead blocks due to the wallet hanging to no issues in the last 24 hours (no wasted mining).

Just quick and dirty hack (this is code for "It could have been done in a nicer way") which seems to have sorted out a big source pain for my little 4-core mining rig.

Oh, this might also address stratum mining issues this coin seems to have.  Monotonic coins don't go 15+ minutes without a transactions (i.e network traffic) so they would not see this issue.

Regards,

--
bsunau7