0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-02-03 09:56:38 -05:00

Remove m_is_manual_connection from CNodeState

Currently, this member is only used to exclude MANUAL peers from discouragement
in MaybePunishNodeForBlock(). Manual connections are already protected in
MaybeDiscourageAndDisconnect(), independently from their network
processing behaviors.
This commit is contained in:
Antoine Riard 2020-12-10 12:47:18 -05:00
parent b76abae387
commit a33442fdc7

View file

@ -376,17 +376,14 @@ struct CNodeState {
//! Whether this peer is an inbound connection //! Whether this peer is an inbound connection
bool m_is_inbound; bool m_is_inbound;
//! Whether this peer is a manual connection
bool m_is_manual_connection;
//! A rolling bloom filter of all announced tx CInvs to this peer. //! A rolling bloom filter of all announced tx CInvs to this peer.
CRollingBloomFilter m_recently_announced_invs = CRollingBloomFilter{INVENTORY_MAX_RECENT_RELAY, 0.000001}; CRollingBloomFilter m_recently_announced_invs = CRollingBloomFilter{INVENTORY_MAX_RECENT_RELAY, 0.000001};
//! Whether this peer relays txs via wtxid //! Whether this peer relays txs via wtxid
bool m_wtxid_relay{false}; bool m_wtxid_relay{false};
CNodeState(CAddress addrIn, bool is_inbound, bool is_manual) CNodeState(CAddress addrIn, bool is_inbound)
: address(addrIn), m_is_inbound(is_inbound), m_is_manual_connection(is_manual) : address(addrIn), m_is_inbound(is_inbound)
{ {
pindexBestKnownBlock = nullptr; pindexBestKnownBlock = nullptr;
hashLastUnknownBlock.SetNull(); hashLastUnknownBlock.SetNull();
@ -754,7 +751,7 @@ void PeerManager::InitializeNode(CNode *pnode) {
NodeId nodeid = pnode->GetId(); NodeId nodeid = pnode->GetId();
{ {
LOCK(cs_main); LOCK(cs_main);
mapNodeState.emplace_hint(mapNodeState.end(), std::piecewise_construct, std::forward_as_tuple(nodeid), std::forward_as_tuple(addr, pnode->IsInboundConn(), pnode->IsManualConn())); mapNodeState.emplace_hint(mapNodeState.end(), std::piecewise_construct, std::forward_as_tuple(nodeid), std::forward_as_tuple(addr, pnode->IsInboundConn()));
assert(m_txrequest.Count(nodeid) == 0); assert(m_txrequest.Count(nodeid) == 0);
} }
{ {
@ -1054,8 +1051,8 @@ bool PeerManager::MaybePunishNodeForBlock(NodeId nodeid, const BlockValidationSt
} }
// Discourage outbound (but not inbound) peers if on an invalid chain. // Discourage outbound (but not inbound) peers if on an invalid chain.
// Exempt HB compact block peers and manual connections. // Exempt HB compact block peers. Manual connections are always protected from discouragement.
if (!via_compact_block && !node_state->m_is_inbound && !node_state->m_is_manual_connection) { if (!via_compact_block && !node_state->m_is_inbound) {
Misbehaving(nodeid, 100, message); Misbehaving(nodeid, 100, message);
return true; return true;
} }