Skip to content

Commit

Permalink
Merge 6bc1eca into merged_master (Bitcoin PR bitcoin/bitcoin#22144)
Browse files Browse the repository at this point in the history
  • Loading branch information
apoelstra committed Jul 25, 2021
2 parents ee13854 + 6bc1eca commit ebffc84
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2213,6 +2213,7 @@ void CConnman::OpenNetworkConnection(const CAddress& addrConnect, bool fCountFai

void CConnman::ThreadMessageHandler()
{
FastRandomContext rng;
while (!flagInterruptMsgProc)
{
std::vector<CNode*> vNodesCopy;
Expand All @@ -2226,6 +2227,11 @@ void CConnman::ThreadMessageHandler()

bool fMoreWork = false;

// Randomize the order in which we process messages from/to our peers.
// This prevents attacks in which an attacker exploits having multiple
// consecutive connections in the vNodes list.
Shuffle(vNodesCopy.begin(), vNodesCopy.end(), rng);

for (CNode* pnode : vNodesCopy)
{
if (pnode->fDisconnect)
Expand Down

0 comments on commit ebffc84

Please sign in to comment.