diff --git a/src/net.cpp b/src/net.cpp index 7b397e8c8..6ab083322 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -2386,6 +2386,8 @@ CNode::CNode(SOCKET hSocketIn, const CAddress& addrIn, const std::string& addrNa addr = addrIn; addrName = addrNameIn == "" ? addr.ToStringIPPort() : addrNameIn; nVersion = 0; + nNumWarningsSkipped = 0; + nLastWarningTime = 0; strSubVer = ""; fWhitelisted = false; fOneShot = false; @@ -2446,8 +2448,16 @@ CNode::~CNode() void CNode::AskFor(const CInv& inv) { if (mapAskFor.size() > MAPASKFOR_MAX_SZ || setAskFor.size() > SETASKFOR_MAX_SZ) { - LogPrintf("CNode::AskFor -- WARNING: inventory message dropped: mapAskFor.size = %d, setAskFor.size = %d, MAPASKFOR_MAX_SZ = %d, SETASKFOR_MAX_SZ = %d, peer=%d\n", - mapAskFor.size(), setAskFor.size(), MAPASKFOR_MAX_SZ, SETASKFOR_MAX_SZ, id); + int64_t nNow = GetTime(); + if(nNow - nLastWarningTime > WARNING_INTERVAL) { + LogPrintf("CNode::AskFor -- WARNING: inventory message dropped: mapAskFor.size = %d, setAskFor.size = %d, MAPASKFOR_MAX_SZ = %d, SETASKFOR_MAX_SZ = %d, nSkipped = %d, peer=%d\n", + mapAskFor.size(), setAskFor.size(), MAPASKFOR_MAX_SZ, SETASKFOR_MAX_SZ, nNumWarningsSkipped, id); + nLastWarningTime = nNow; + nNumWarningsSkipped = 0; + } + else { + ++nNumWarningsSkipped; + } return; } // a peer may not have multiple non-responded queue positions for a single inv item diff --git a/src/net.h b/src/net.h index bc57c8457..27f578507 100644 --- a/src/net.h +++ b/src/net.h @@ -40,6 +40,8 @@ namespace boost { 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; +/** Minimum time between warnings printed to log. */ +static const int WARNING_INTERVAL = 10 * 60; /** The maximum number of entries in an 'inv' protocol message */ static const unsigned int MAX_INV_SZ = 50000; /** The maximum number of new addresses to accumulate before announcing. */ @@ -336,9 +338,11 @@ public: int64_t nLastRecv; int64_t nTimeConnected; int64_t nTimeOffset; + int64_t nLastWarningTime; CAddress addr; std::string addrName; CService addrLocal; + int nNumWarningsSkipped; int nVersion; // strSubVer is whatever byte array we read from the wire. However, this field is intended // to be printed out, displayed to humans in various forms and so on. So we sanitize it and