Skip to content

Commit 844ace9

Browse files
committed
Merge pull request #5507
c907704 DOS: Respect max per-peer blocks in flight limit (Adam Weiss)
2 parents 055f3ae + c907704 commit 844ace9

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/main.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3597,7 +3597,9 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
35973597
// doing this will result in the received block being rejected as an orphan in case it is
35983598
// not a direct successor.
35993599
pfrom->PushMessage("getheaders", chainActive.GetLocator(pindexBestHeader), inv.hash);
3600-
if (chainActive.Tip()->GetBlockTime() > GetAdjustedTime() - Params().TargetSpacing() * 20) {
3600+
CNodeState *nodestate = State(pfrom->GetId());
3601+
if (chainActive.Tip()->GetBlockTime() > GetAdjustedTime() - Params().TargetSpacing() * 20 &&
3602+
nodestate->nBlocksInFlight < MAX_BLOCKS_IN_TRANSIT_PER_PEER) {
36013603
vToFetch.push_back(inv);
36023604
// Mark block as in flight already, even though the actual "getdata" message only goes out
36033605
// later (within the same cs_main lock, though).

0 commit comments

Comments
 (0)