Skip to content

Commit

Permalink
Merge bitcoin#16188: net: Document what happens to getdata of unknown…
Browse files Browse the repository at this point in the history
… type

dddd927 net: Document what happens to getdata of unknonw type (MarcoFalke)

Pull request description:

  Any getdata of unknown type will never be processed and blocks all future messages from a peer. This isn't obviously clear from reading the code, so document it.

Top commit has no ACKs.

Tree-SHA512: 4f8e43bbe6534242facfcfffae28b7a6aa2d228841fa2146a87d494e69f614b0da23cf7a5f3d4367358a7c1981fe2ec196a21c437ae1653f1c7e0351be22598a
  • Loading branch information
fanquake authored and PastaPastaPasta committed Jul 13, 2021
1 parent d37c1fc commit e406089
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/net_processing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1748,6 +1748,11 @@ void static ProcessGetData(CNode* pfrom, const CChainParams& chainparams, CConnm
}
}

// Unknown types in the GetData stay in vRecvGetData and block any future
// message from this peer, see vRecvGetData check in ProcessMessages().
// Depending on future p2p changes, we might either drop unknown getdata on
// the floor or disconnect the peer.

pfrom->vRecvGetData.erase(pfrom->vRecvGetData.begin(), it);

if (!vNotFound.empty()) {
Expand Down Expand Up @@ -3696,6 +3701,7 @@ bool PeerLogicValidation::ProcessMessages(CNode* pfrom, std::atomic<bool>& inter
return false;

// this maintains the order of responses
// and prevents vRecvGetData to grow unbounded
if (!pfrom->vRecvGetData.empty()) return true;
if (!pfrom->orphan_work_set.empty()) return true;

Expand Down

0 comments on commit e406089

Please sign in to comment.