diff options
author | Adam Weiss <adam@signal11.com> | 2014-12-18 18:28:29 -0500 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2014-12-23 12:36:26 +0100 |
commit | d10a9015ad324d03664ccbccfd23953733c6dc59 (patch) | |
tree | 78c8c7bf39de95c191a891c657898068f73d2ec5 /src | |
parent | 15ad0b54fab09d31ab7171b83ef58fa4c5f4aea9 (diff) | |
download | bitcoin-d10a9015ad324d03664ccbccfd23953733c6dc59.tar.xz |
DOS: Respect max per-peer blocks in flight limit
Don't allow immediate inv driven block downloads if
a peer already has MAX_BLOCKS_IN_TRANSIT_PER_PEER
active downloads. Prevents bogus inv spam from
blowing up block transfer tracking data structures.
Rebased-From: c90770430d7c1eb7ece2d4ddb987b0f2210fd86f
Github-Pull: #5507
Diffstat (limited to 'src')
-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 4a0008726e..69fb5e2588 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3641,7 +3641,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). |