diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2014-12-23 12:31:35 +0100 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2014-12-23 12:32:47 +0100 |
commit | 844ace95de246bb76103e4759bd385ceb864a2a5 (patch) | |
tree | 32b8303d0dc8f32c6b78068b6abdfcc371a2e395 /src/main.cpp | |
parent | 055f3ae9aaab8731b34d1731a0b26b3527301c01 (diff) | |
parent | c90770430d7c1eb7ece2d4ddb987b0f2210fd86f (diff) | |
download | bitcoin-844ace95de246bb76103e4759bd385ceb864a2a5.tar.xz |
Merge pull request #5507
c907704 DOS: Respect max per-peer blocks in flight limit (Adam Weiss)
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 4 |
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). |