Browse Source

Merge pull request #5507

c907704 DOS: Respect max per-peer blocks in flight limit (Adam Weiss)
0.13
Wladimir J. van der Laan 10 years ago
parent
commit
844ace95de
No known key found for this signature in database
GPG Key ID: 74810B012346C9A6
  1. 4
      src/main.cpp

4
src/main.cpp

@ -3597,7 +3597,9 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, @@ -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).

Loading…
Cancel
Save