mirror of
https://github.com/bitcoin/bitcoin.git
synced 2024-11-20 02:25:40 +01:00
[net] Add connection type getter to CNode
This commit is contained in:
parent
40e1c4d402
commit
ad44aa5c64
@ -917,7 +917,7 @@ bool CConnman::AttemptToEvictConnection()
|
|||||||
.m_is_local = node->addr.IsLocal(),
|
.m_is_local = node->addr.IsLocal(),
|
||||||
.m_network = node->ConnectedThroughNetwork(),
|
.m_network = node->ConnectedThroughNetwork(),
|
||||||
.m_noban = node->HasPermission(NetPermissionFlags::NoBan),
|
.m_noban = node->HasPermission(NetPermissionFlags::NoBan),
|
||||||
.m_conn_type = node->m_conn_type,
|
.m_conn_type = node->GetConnectionType(),
|
||||||
};
|
};
|
||||||
vEvictionCandidates.push_back(candidate);
|
vEvictionCandidates.push_back(candidate);
|
||||||
}
|
}
|
||||||
@ -1092,7 +1092,7 @@ bool CConnman::AddConnection(const std::string& address, ConnectionType conn_typ
|
|||||||
|
|
||||||
// Count existing connections
|
// Count existing connections
|
||||||
int existing_connections = WITH_LOCK(m_nodes_mutex,
|
int existing_connections = WITH_LOCK(m_nodes_mutex,
|
||||||
return std::count_if(m_nodes.begin(), m_nodes.end(), [conn_type](CNode* node) { return node->m_conn_type == conn_type; }););
|
return std::count_if(m_nodes.begin(), m_nodes.end(), [conn_type](CNode* node) { return node->GetConnectionType() == conn_type; }););
|
||||||
|
|
||||||
// Max connections of specified type already exist
|
// Max connections of specified type already exist
|
||||||
if (max_connections != std::nullopt && existing_connections >= max_connections) return false;
|
if (max_connections != std::nullopt && existing_connections >= max_connections) return false;
|
||||||
@ -1722,7 +1722,7 @@ void CConnman::ThreadOpenConnections(const std::vector<std::string> connect)
|
|||||||
if (pnode->IsBlockOnlyConn()) nOutboundBlockRelay++;
|
if (pnode->IsBlockOnlyConn()) nOutboundBlockRelay++;
|
||||||
|
|
||||||
// Make sure our persistent outbound slots belong to different netgroups.
|
// Make sure our persistent outbound slots belong to different netgroups.
|
||||||
switch (pnode->m_conn_type) {
|
switch (pnode->GetConnectionType()) {
|
||||||
// We currently don't take inbound connections into account. Since they are
|
// 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
|
// free to make, an attacker could make them to prevent us from connecting to
|
||||||
// certain peers.
|
// certain peers.
|
||||||
|
@ -417,6 +417,11 @@ public:
|
|||||||
std::atomic_bool fPauseRecv{false};
|
std::atomic_bool fPauseRecv{false};
|
||||||
std::atomic_bool fPauseSend{false};
|
std::atomic_bool fPauseSend{false};
|
||||||
|
|
||||||
|
const ConnectionType& GetConnectionType() const
|
||||||
|
{
|
||||||
|
return m_conn_type;
|
||||||
|
}
|
||||||
|
|
||||||
bool IsOutboundOrBlockRelayConn() const {
|
bool IsOutboundOrBlockRelayConn() const {
|
||||||
switch (m_conn_type) {
|
switch (m_conn_type) {
|
||||||
case ConnectionType::OUTBOUND_FULL_RELAY:
|
case ConnectionType::OUTBOUND_FULL_RELAY:
|
||||||
|
Loading…
Reference in New Issue
Block a user