|
|
@ -28,6 +28,7 @@
|
|
|
|
#include <boost/signals2/signal.hpp>
|
|
|
|
#include <boost/signals2/signal.hpp>
|
|
|
|
#include <openssl/rand.h>
|
|
|
|
#include <openssl/rand.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CAddrMan;
|
|
|
|
class CAddrMan;
|
|
|
|
class CBlockIndex;
|
|
|
|
class CBlockIndex;
|
|
|
|
class CNode;
|
|
|
|
class CNode;
|
|
|
@ -36,6 +37,10 @@ namespace boost {
|
|
|
|
class thread_group;
|
|
|
|
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 */
|
|
|
|
/** The maximum number of entries in an 'inv' protocol message */
|
|
|
|
static const unsigned int MAX_INV_SZ = 50000;
|
|
|
|
static const unsigned int MAX_INV_SZ = 50000;
|
|
|
|
/** -listen default */
|
|
|
|
/** -listen default */
|
|
|
@ -219,7 +224,6 @@ public:
|
|
|
|
|
|
|
|
|
|
|
|
int64_t nLastSend;
|
|
|
|
int64_t nLastSend;
|
|
|
|
int64_t nLastRecv;
|
|
|
|
int64_t nLastRecv;
|
|
|
|
int64_t nLastSendEmpty;
|
|
|
|
|
|
|
|
int64_t nTimeConnected;
|
|
|
|
int64_t nTimeConnected;
|
|
|
|
CAddress addr;
|
|
|
|
CAddress addr;
|
|
|
|
std::string addrName;
|
|
|
|
std::string addrName;
|
|
|
@ -275,10 +279,14 @@ public:
|
|
|
|
CCriticalSection cs_inventory;
|
|
|
|
CCriticalSection cs_inventory;
|
|
|
|
std::multimap<int64_t, CInv> mapAskFor;
|
|
|
|
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;
|
|
|
|
uint64_t nPingNonceSent;
|
|
|
|
|
|
|
|
// Time (in usec) the last ping was sent, or 0 if no ping was ever sent.
|
|
|
|
int64_t nPingUsecStart;
|
|
|
|
int64_t nPingUsecStart;
|
|
|
|
|
|
|
|
// Last measured round-trip time.
|
|
|
|
int64_t nPingUsecTime;
|
|
|
|
int64_t nPingUsecTime;
|
|
|
|
|
|
|
|
// Whether a ping is requested.
|
|
|
|
bool fPingQueued;
|
|
|
|
bool fPingQueued;
|
|
|
|
|
|
|
|
|
|
|
|
CNode(SOCKET hSocketIn, CAddress addrIn, std::string addrNameIn = "", bool fInboundIn=false) : ssSend(SER_NETWORK, INIT_PROTO_VERSION), setAddrKnown(5000)
|
|
|
|
CNode(SOCKET hSocketIn, CAddress addrIn, std::string addrNameIn = "", bool fInboundIn=false) : ssSend(SER_NETWORK, INIT_PROTO_VERSION), setAddrKnown(5000)
|
|
|
@ -290,7 +298,6 @@ public:
|
|
|
|
nLastRecv = 0;
|
|
|
|
nLastRecv = 0;
|
|
|
|
nSendBytes = 0;
|
|
|
|
nSendBytes = 0;
|
|
|
|
nRecvBytes = 0;
|
|
|
|
nRecvBytes = 0;
|
|
|
|
nLastSendEmpty = GetTime();
|
|
|
|
|
|
|
|
nTimeConnected = GetTime();
|
|
|
|
nTimeConnected = GetTime();
|
|
|
|
addr = addrIn;
|
|
|
|
addr = addrIn;
|
|
|
|
addrName = addrNameIn == "" ? addr.ToStringIPPort() : addrNameIn;
|
|
|
|
addrName = addrNameIn == "" ? addr.ToStringIPPort() : addrNameIn;
|
|
|
|