diff options
author | Pieter Wuille <pieter.wuille@gmail.com> | 2013-10-15 00:34:20 +0200 |
---|---|---|
committer | Pieter Wuille <pieter.wuille@gmail.com> | 2014-06-09 23:06:56 +0200 |
commit | f1920e86063d0ed008c6028d8223b0e21889bf75 (patch) | |
tree | 73819080978357908611074ede88c08d503dadc2 /src/net.h | |
parent | 6741837233eec841f84131548befcfea8ebf6f14 (diff) |
Ping automatically every 2 minutes (unconditionally)
... instead of after 30 minutes of no sending, for latency measurement
and keep-alive. Also, disconnect if no reply arrives within 20 minutes,
instead of 90 of inactivity (for peers supporting the 'pong' message).
Diffstat (limited to 'src/net.h')
-rw-r--r-- | src/net.h | 13 |
1 files changed, 10 insertions, 3 deletions
@@ -28,6 +28,7 @@ #include <boost/signals2/signal.hpp> #include <openssl/rand.h> + class CAddrMan; class CBlockIndex; class CNode; @@ -36,6 +37,10 @@ namespace boost { class thread_group; } +/** Time between pings automatically sent out for latency probing and keepalive (in seconds). */ +static const int PING_INTERVAL = 2 * 60; +/** Time after which to disconnect, after waiting for a ping response (or inactivity). */ +static const int TIMEOUT_INTERVAL = 20 * 60; /** The maximum number of entries in an 'inv' protocol message */ static const unsigned int MAX_INV_SZ = 50000; /** -upnp default */ @@ -217,7 +222,6 @@ public: int64_t nLastSend; int64_t nLastRecv; - int64_t nLastSendEmpty; int64_t nTimeConnected; CAddress addr; std::string addrName; @@ -273,10 +277,14 @@ public: CCriticalSection cs_inventory; std::multimap<int64_t, CInv> mapAskFor; - // Ping time measurement + // Ping time measurement: + // The pong reply we're expecting, or 0 if no pong expected. uint64_t nPingNonceSent; + // Time (in usec) the last ping was sent, or 0 if no ping was ever sent. int64_t nPingUsecStart; + // Last measured round-trip time. int64_t nPingUsecTime; + // Whether a ping is requested. bool fPingQueued; CNode(SOCKET hSocketIn, CAddress addrIn, std::string addrNameIn = "", bool fInboundIn=false) : ssSend(SER_NETWORK, INIT_PROTO_VERSION), setAddrKnown(5000) @@ -288,7 +296,6 @@ public: nLastRecv = 0; nSendBytes = 0; nRecvBytes = 0; - nLastSendEmpty = GetTime(); nTimeConnected = GetTime(); addr = addrIn; addrName = addrNameIn == "" ? addr.ToStringIPPort() : addrNameIn; |