mirror of
https://github.com/dashpay/dash.git
synced 2024-12-27 13:03:17 +01:00
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: c90770430d
Github-Pull: #5507
This commit is contained in:
parent
15ad0b54fa
commit
d10a9015ad
@ -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
|
// doing this will result in the received block being rejected as an orphan in case it is
|
||||||
// not a direct successor.
|
// not a direct successor.
|
||||||
pfrom->PushMessage("getheaders", chainActive.GetLocator(pindexBestHeader), inv.hash);
|
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);
|
vToFetch.push_back(inv);
|
||||||
// Mark block as in flight already, even though the actual "getdata" message only goes out
|
// Mark block as in flight already, even though the actual "getdata" message only goes out
|
||||||
// later (within the same cs_main lock, though).
|
// later (within the same cs_main lock, though).
|
||||||
|
Loading…
Reference in New Issue
Block a user