mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-08 10:31:50 -05:00
Randomize message processing peer order
This commit is contained in:
parent
2aab8a6dd0
commit
79c02c88b3
1 changed files with 6 additions and 0 deletions
|
@ -2173,6 +2173,7 @@ void CConnman::OpenNetworkConnection(const CAddress& addrConnect, bool fCountFai
|
|||
|
||||
void CConnman::ThreadMessageHandler()
|
||||
{
|
||||
FastRandomContext rng;
|
||||
while (!flagInterruptMsgProc)
|
||||
{
|
||||
std::vector<CNode*> vNodesCopy;
|
||||
|
@ -2186,6 +2187,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)
|
||||
|
|
Loading…
Add table
Reference in a new issue