mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-11 01:26:10 +01:00
p2p: Diversify connections only w.r.t *persistent* outbound peers
ADDR_FETCH and FEELER are short-lived connections, and they should not affect our choice of peers. Also, improve comments.
This commit is contained in:
parent
8c4958bd4c
commit
3faae99c3d
1 changed files with 10 additions and 7 deletions
17
src/net.cpp
17
src/net.cpp
|
@ -1721,19 +1721,22 @@ void CConnman::ThreadOpenConnections(const std::vector<std::string> connect)
|
|||
if (pnode->IsFullOutboundConn()) nOutboundFullRelay++;
|
||||
if (pnode->IsBlockOnlyConn()) nOutboundBlockRelay++;
|
||||
|
||||
// Netgroups for inbound and manual peers are not excluded because our goal here
|
||||
// is to not use multiple of our limited outbound slots on a single netgroup
|
||||
// but inbound and manual peers do not use our outbound slots. Inbound peers
|
||||
// also have the added issue that they could be attacker controlled and used
|
||||
// to prevent us from connecting to particular hosts if we used them here.
|
||||
// Make sure our persistent outbound slots belong to different netgroups.
|
||||
switch (pnode->m_conn_type) {
|
||||
// We currently don't take inbound connections into account. Since they are
|
||||
// free to make, an attacker could make them to prevent us from connecting to
|
||||
// certain peers.
|
||||
case ConnectionType::INBOUND:
|
||||
// Manually selected connections should not affect how we select outbound
|
||||
// peers from addrman.
|
||||
case ConnectionType::MANUAL:
|
||||
// Short-lived outbound connections should not affect how we select outbound
|
||||
// peers from addrman.
|
||||
case ConnectionType::ADDR_FETCH:
|
||||
case ConnectionType::FEELER:
|
||||
break;
|
||||
case ConnectionType::OUTBOUND_FULL_RELAY:
|
||||
case ConnectionType::BLOCK_RELAY:
|
||||
case ConnectionType::ADDR_FETCH:
|
||||
case ConnectionType::FEELER:
|
||||
setConnected.insert(m_netgroupman.GetGroup(pnode->addr));
|
||||
} // no default case, so the compiler can warn about missing cases
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue