Skip to content

Commit bc5d65b

Browse files
committed
[refactor] Remove IsOutboundDisconnectionCandidate
1 parent 2f2e13b commit bc5d65b

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

src/net_processing.cpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -827,11 +827,6 @@ void UpdateLastBlockAnnounceTime(NodeId node, int64_t time_in_seconds)
827827
if (state) state->m_last_block_announcement = time_in_seconds;
828828
}
829829

830-
static bool IsOutboundDisconnectionCandidate(const CNode& node)
831-
{
832-
return node.IsOutboundOrBlockRelayConn();
833-
}
834-
835830
void PeerLogicValidation::InitializeNode(CNode *pnode) {
836831
CAddress addr = pnode->addr;
837832
std::string addrName = pnode->GetAddrName();
@@ -1963,14 +1958,14 @@ static void ProcessHeadersMessage(CNode& pfrom, CConnman& connman, ChainstateMan
19631958
// until we have a headers chain that has at least
19641959
// nMinimumChainWork, even if a peer has a chain past our tip,
19651960
// as an anti-DoS measure.
1966-
if (IsOutboundDisconnectionCandidate(pfrom)) {
1961+
if (pfrom.IsOutboundOrBlockRelayConn()) {
19671962
LogPrintf("Disconnecting outbound peer %d -- headers chain has insufficient work\n", pfrom.GetId());
19681963
pfrom.fDisconnect = true;
19691964
}
19701965
}
19711966
}
19721967

1973-
if (!pfrom.fDisconnect && IsOutboundDisconnectionCandidate(pfrom) && nodestate->pindexBestKnownBlock != nullptr && pfrom.m_tx_relay != nullptr) {
1968+
if (!pfrom.fDisconnect && pfrom.IsOutboundOrBlockRelayConn() && nodestate->pindexBestKnownBlock != nullptr && pfrom.m_tx_relay != nullptr) {
19741969
// If this is an outbound full-relay peer, check to see if we should protect
19751970
// it from the bad/lagging chain logic.
19761971
// Note that block-relay-only peers are already implicitly protected, so we
@@ -3854,7 +3849,7 @@ void PeerLogicValidation::ConsiderEviction(CNode& pto, int64_t time_in_seconds)
38543849
CNodeState &state = *State(pto.GetId());
38553850
const CNetMsgMaker msgMaker(pto.GetSendVersion());
38563851

3857-
if (!state.m_chain_sync.m_protect && IsOutboundDisconnectionCandidate(pto) && state.fSyncStarted) {
3852+
if (!state.m_chain_sync.m_protect && pto.IsOutboundOrBlockRelayConn() && state.fSyncStarted) {
38583853
// This is an outbound peer subject to disconnection if they don't
38593854
// announce a block with as much work as the current tip within
38603855
// CHAIN_SYNC_TIMEOUT + HEADERS_RESPONSE_TIME seconds (note: if
@@ -3916,7 +3911,7 @@ void PeerLogicValidation::EvictExtraOutboundPeers(int64_t time_in_seconds)
39163911
AssertLockHeld(cs_main);
39173912

39183913
// Ignore non-outbound peers, or nodes marked for disconnect already
3919-
if (!IsOutboundDisconnectionCandidate(*pnode) || pnode->fDisconnect) return;
3914+
if (!pnode->IsOutboundOrBlockRelayConn() || pnode->fDisconnect) return;
39203915
CNodeState *state = State(pnode->GetId());
39213916
if (state == nullptr) return; // shouldn't be possible, but just in case
39223917
// Don't evict our protected peers

0 commit comments

Comments
 (0)