Skip to content

Commit 1492342

Browse files
committed
[net/refactor] Remove fFeeler flag from CNode
1 parent 49efac5 commit 1492342

File tree

4 files changed

+10
-12
lines changed

4 files changed

+10
-12
lines changed

src/net.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1648,7 +1648,7 @@ void CConnman::ThreadDNSAddressSeed()
16481648
{
16491649
LOCK(cs_vNodes);
16501650
for (const CNode* pnode : vNodes) {
1651-
nRelevant += pnode->fSuccessfullyConnected && !pnode->fFeeler && !pnode->m_addr_fetch && !pnode->IsManualConn() && !pnode->fInbound;
1651+
nRelevant += pnode->fSuccessfullyConnected && !pnode->IsFeelerConn() && !pnode->m_addr_fetch && !pnode->IsManualConn() && !pnode->fInbound;
16521652
}
16531653
}
16541654
if (nRelevant >= 2) {
@@ -1758,7 +1758,7 @@ int CConnman::GetExtraOutboundCount()
17581758
{
17591759
LOCK(cs_vNodes);
17601760
for (const CNode* pnode : vNodes) {
1761-
if (!pnode->fInbound && !pnode->IsManualConn() && !pnode->fFeeler && !pnode->fDisconnect && !pnode->m_addr_fetch && pnode->fSuccessfullyConnected) {
1761+
if (!pnode->fInbound && !pnode->IsManualConn() && !pnode->IsFeelerConn() && !pnode->fDisconnect && !pnode->m_addr_fetch && pnode->fSuccessfullyConnected) {
17621762
++nOutbound;
17631763
}
17641764
}
@@ -1841,7 +1841,7 @@ void CConnman::ThreadOpenConnections(const std::vector<std::string> connect)
18411841
setConnected.insert(pnode->addr.GetGroup(addrman.m_asmap));
18421842
if (pnode->m_tx_relay == nullptr) {
18431843
nOutboundBlockRelay++;
1844-
} else if (!pnode->fFeeler) {
1844+
} else if (!pnode->IsFeelerConn()) {
18451845
nOutboundFullRelay++;
18461846
}
18471847
}
@@ -2739,7 +2739,6 @@ CNode::CNode(NodeId idIn, ServiceFlags nLocalServicesIn, int nMyStartingHeightIn
27392739
: nTimeConnected(GetSystemTimeInSeconds()),
27402740
addr(addrIn),
27412741
addrBind(addrBindIn),
2742-
fFeeler(conn_type_in == ConnectionType::FEELER),
27432742
m_addr_fetch(conn_type_in == ConnectionType::ADDR_FETCH),
27442743
fInbound(conn_type_in == ConnectionType::INBOUND),
27452744
nKeyedNetGroup(nKeyedNetGroupIn),

src/net.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,6 @@ class CNode
775775
}
776776
// This boolean is unusued in actual processing, only present for backward compatibility at RPC/QT level
777777
bool m_legacyWhitelisted{false};
778-
bool fFeeler{false}; // If true this node is being used as a short lived feeler.
779778
bool m_addr_fetch{false};
780779
bool fClient{false}; // set by version message
781780
bool m_limited_node{false}; //after BIP159, set by version message
@@ -796,6 +795,10 @@ class CNode
796795
return m_conn_type == ConnectionType::MANUAL;
797796
}
798797

798+
bool IsFeelerConn() const {
799+
return m_conn_type == ConnectionType::FEELER;
800+
}
801+
799802
protected:
800803
mapMsgCmdSize mapSendBytesPerMsgCmd;
801804
mapMsgCmdSize mapRecvBytesPerMsgCmd GUARDED_BY(cs_vRecv);

src/net_processing.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,7 @@ void UpdateLastBlockAnnounceTime(NodeId node, int64_t time_in_seconds)
829829

830830
static bool IsOutboundDisconnectionCandidate(const CNode& node)
831831
{
832-
return !(node.fInbound || node.IsManualConn() || node.fFeeler || node.m_addr_fetch);
832+
return !(node.fInbound || node.IsManualConn() || node.IsFeelerConn() || node.m_addr_fetch);
833833
}
834834

835835
void PeerLogicValidation::InitializeNode(CNode *pnode) {
@@ -2324,7 +2324,7 @@ void ProcessMessage(
23242324
{
23252325
connman.SetServices(pfrom.addr, nServices);
23262326
}
2327-
if (!pfrom.fInbound && !pfrom.fFeeler && !pfrom.IsManualConn() && !HasAllDesirableServiceFlags(nServices))
2327+
if (!pfrom.fInbound && !pfrom.IsFeelerConn() && !pfrom.IsManualConn() && !HasAllDesirableServiceFlags(nServices))
23282328
{
23292329
LogPrint(BCLog::NET, "peer=%d does not offer the expected services (%08x offered, %08x expected); disconnecting\n", pfrom.GetId(), nServices, GetDesirableServiceFlags(nServices));
23302330
pfrom.fDisconnect = true;
@@ -2452,8 +2452,7 @@ void ProcessMessage(
24522452
}
24532453

24542454
// Feeler connections exist only to verify if address is online.
2455-
if (pfrom.fFeeler) {
2456-
assert(pfrom.fInbound == false);
2455+
if (pfrom.IsFeelerConn()) {
24572456
pfrom.fDisconnect = true;
24582457
}
24592458
return;

src/test/net_tests.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,14 +181,11 @@ BOOST_AUTO_TEST_CASE(cnode_simple_test)
181181
CAddress addr = CAddress(CService(ipv4Addr, 7777), NODE_NETWORK);
182182
std::string pszDest;
183183

184-
// Test that fFeeler is false by default.
185184
std::unique_ptr<CNode> pnode1 = MakeUnique<CNode>(id++, NODE_NETWORK, height, hSocket, addr, 0, 0, CAddress(), pszDest, ConnectionType::OUTBOUND);
186185
BOOST_CHECK(pnode1->fInbound == false);
187-
BOOST_CHECK(pnode1->fFeeler == false);
188186

189187
std::unique_ptr<CNode> pnode2 = MakeUnique<CNode>(id++, NODE_NETWORK, height, hSocket, addr, 1, 1, CAddress(), pszDest, ConnectionType::INBOUND);
190188
BOOST_CHECK(pnode2->fInbound == true);
191-
BOOST_CHECK(pnode2->fFeeler == false);
192189
}
193190

194191
// prior to PR #14728, this test triggers an undefined behavior

0 commit comments

Comments
 (0)