aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWladimir J. van der Laan <[email protected]>2014-09-10 16:47:40 +0200
committerWladimir J. van der Laan <[email protected]>2014-09-10 16:52:57 +0200
commitd6af9856b0a3140dfa143cd8261efef91f7f3e76 (patch)
tree7a02fe301e87390d1b2f08fefa6daaa92f0986b4 /src
parentMerge pull request #4623 (diff)
parentAvoid returning many "inv" orphans (diff)
downloaddiscoin-d6af9856b0a3140dfa143cd8261efef91f7f3e76.tar.xz
discoin-d6af9856b0a3140dfa143cd8261efef91f7f3e76.zip
Merge pull request #4878
540ac45 Avoid returning many "inv" orphans (Jeff Garzik) d4168c8 Limit CNode::mapAskFor (Wladimir J. van der Laan)
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp5
-rw-r--r--src/net.cpp2
-rw-r--r--src/net.h2
3 files changed, 9 insertions, 0 deletions
diff --git a/src/main.cpp b/src/main.cpp
index bbe5bd87f..f063a48fe 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -3641,6 +3641,11 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
// Track requests for our stuff
g_signals.Inventory(inv.hash);
+
+ if (pfrom->nSendSize > (SendBufferSize() * 2)) {
+ Misbehaving(pfrom->GetId(), 50);
+ return error("send buffer size() = %u", pfrom->nSendSize);
+ }
}
}
diff --git a/src/net.cpp b/src/net.cpp
index 633a3a34e..b18944a26 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -2106,6 +2106,8 @@ CNode::~CNode()
void CNode::AskFor(const CInv& inv)
{
+ if (mapAskFor.size() > MAPASKFOR_MAX_SZ)
+ return;
// We're using mapAskFor as a priority queue,
// the key is the earliest time the request can be sent
int64_t nRequestTime;
diff --git a/src/net.h b/src/net.h
index e2700c097..ad0a1df7e 100644
--- a/src/net.h
+++ b/src/net.h
@@ -51,6 +51,8 @@ static const bool DEFAULT_UPNP = USE_UPNP;
#else
static const bool DEFAULT_UPNP = false;
#endif
+/** The maximum number of entries in mapAskFor */
+static const size_t MAPASKFOR_MAX_SZ = MAX_INV_SZ;
unsigned int ReceiveFloodSize();
unsigned int SendBufferSize();