aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2014-12-23 12:31:35 +0100
committerWladimir J. van der Laan <laanwj@gmail.com>2014-12-23 12:32:47 +0100
commit844ace95de246bb76103e4759bd385ceb864a2a5 (patch)
tree32b8303d0dc8f32c6b78068b6abdfcc371a2e395
parent055f3ae9aaab8731b34d1731a0b26b3527301c01 (diff)
parentc90770430d7c1eb7ece2d4ddb987b0f2210fd86f (diff)
Merge pull request #5507
c907704 DOS: Respect max per-peer blocks in flight limit (Adam Weiss)
-rw-r--r--src/main.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 762a404032..2410230ef4 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -3597,7 +3597,9 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
// doing this will result in the received block being rejected as an orphan in case it is
// not a direct successor.
pfrom->PushMessage("getheaders", chainActive.GetLocator(pindexBestHeader), inv.hash);
- if (chainActive.Tip()->GetBlockTime() > GetAdjustedTime() - Params().TargetSpacing() * 20) {
+ CNodeState *nodestate = State(pfrom->GetId());
+ if (chainActive.Tip()->GetBlockTime() > GetAdjustedTime() - Params().TargetSpacing() * 20 &&
+ nodestate->nBlocksInFlight < MAX_BLOCKS_IN_TRANSIT_PER_PEER) {
vToFetch.push_back(inv);
// Mark block as in flight already, even though the actual "getdata" message only goes out
// later (within the same cs_main lock, though).