aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAmiti Uttarwar <amiti@uttarwar.org>2020-05-12 12:58:41 -0700
committerAmiti Uttarwar <amiti@uttarwar.org>2020-08-07 17:18:16 -0700
commit14923422b08ac4b21b35c426bf0e1b9e7c97983b (patch)
tree678645398fc7e75093828cb8200e7ca9fed2ae3b /src
parent49efac5cae7333c6700d9b737d09fae0f3f4d7fa (diff)
downloadbitcoin-14923422b08ac4b21b35c426bf0e1b9e7c97983b.tar.xz
[net/refactor] Remove fFeeler flag from CNode
Diffstat (limited to 'src')
-rw-r--r--src/net.cpp7
-rw-r--r--src/net.h5
-rw-r--r--src/net_processing.cpp7
-rw-r--r--src/test/net_tests.cpp3
4 files changed, 10 insertions, 12 deletions
diff --git a/src/net.cpp b/src/net.cpp
index 4270b16d56..047153972e 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -1648,7 +1648,7 @@ void CConnman::ThreadDNSAddressSeed()
{
LOCK(cs_vNodes);
for (const CNode* pnode : vNodes) {
- nRelevant += pnode->fSuccessfullyConnected && !pnode->fFeeler && !pnode->m_addr_fetch && !pnode->IsManualConn() && !pnode->fInbound;
+ nRelevant += pnode->fSuccessfullyConnected && !pnode->IsFeelerConn() && !pnode->m_addr_fetch && !pnode->IsManualConn() && !pnode->fInbound;
}
}
if (nRelevant >= 2) {
@@ -1758,7 +1758,7 @@ int CConnman::GetExtraOutboundCount()
{
LOCK(cs_vNodes);
for (const CNode* pnode : vNodes) {
- if (!pnode->fInbound && !pnode->IsManualConn() && !pnode->fFeeler && !pnode->fDisconnect && !pnode->m_addr_fetch && pnode->fSuccessfullyConnected) {
+ if (!pnode->fInbound && !pnode->IsManualConn() && !pnode->IsFeelerConn() && !pnode->fDisconnect && !pnode->m_addr_fetch && pnode->fSuccessfullyConnected) {
++nOutbound;
}
}
@@ -1841,7 +1841,7 @@ void CConnman::ThreadOpenConnections(const std::vector<std::string> connect)
setConnected.insert(pnode->addr.GetGroup(addrman.m_asmap));
if (pnode->m_tx_relay == nullptr) {
nOutboundBlockRelay++;
- } else if (!pnode->fFeeler) {
+ } else if (!pnode->IsFeelerConn()) {
nOutboundFullRelay++;
}
}
@@ -2739,7 +2739,6 @@ CNode::CNode(NodeId idIn, ServiceFlags nLocalServicesIn, int nMyStartingHeightIn
: nTimeConnected(GetSystemTimeInSeconds()),
addr(addrIn),
addrBind(addrBindIn),
- fFeeler(conn_type_in == ConnectionType::FEELER),
m_addr_fetch(conn_type_in == ConnectionType::ADDR_FETCH),
fInbound(conn_type_in == ConnectionType::INBOUND),
nKeyedNetGroup(nKeyedNetGroupIn),
diff --git a/src/net.h b/src/net.h
index 0c6e939771..f4fd33ec95 100644
--- a/src/net.h
+++ b/src/net.h
@@ -775,7 +775,6 @@ public:
}
// This boolean is unusued in actual processing, only present for backward compatibility at RPC/QT level
bool m_legacyWhitelisted{false};
- bool fFeeler{false}; // If true this node is being used as a short lived feeler.
bool m_addr_fetch{false};
bool fClient{false}; // set by version message
bool m_limited_node{false}; //after BIP159, set by version message
@@ -796,6 +795,10 @@ public:
return m_conn_type == ConnectionType::MANUAL;
}
+ bool IsFeelerConn() const {
+ return m_conn_type == ConnectionType::FEELER;
+ }
+
protected:
mapMsgCmdSize mapSendBytesPerMsgCmd;
mapMsgCmdSize mapRecvBytesPerMsgCmd GUARDED_BY(cs_vRecv);
diff --git a/src/net_processing.cpp b/src/net_processing.cpp
index 62886064eb..53d47b63b3 100644
--- a/src/net_processing.cpp
+++ b/src/net_processing.cpp
@@ -829,7 +829,7 @@ void UpdateLastBlockAnnounceTime(NodeId node, int64_t time_in_seconds)
static bool IsOutboundDisconnectionCandidate(const CNode& node)
{
- return !(node.fInbound || node.IsManualConn() || node.fFeeler || node.m_addr_fetch);
+ return !(node.fInbound || node.IsManualConn() || node.IsFeelerConn() || node.m_addr_fetch);
}
void PeerLogicValidation::InitializeNode(CNode *pnode) {
@@ -2324,7 +2324,7 @@ void ProcessMessage(
{
connman.SetServices(pfrom.addr, nServices);
}
- if (!pfrom.fInbound && !pfrom.fFeeler && !pfrom.IsManualConn() && !HasAllDesirableServiceFlags(nServices))
+ if (!pfrom.fInbound && !pfrom.IsFeelerConn() && !pfrom.IsManualConn() && !HasAllDesirableServiceFlags(nServices))
{
LogPrint(BCLog::NET, "peer=%d does not offer the expected services (%08x offered, %08x expected); disconnecting\n", pfrom.GetId(), nServices, GetDesirableServiceFlags(nServices));
pfrom.fDisconnect = true;
@@ -2452,8 +2452,7 @@ void ProcessMessage(
}
// Feeler connections exist only to verify if address is online.
- if (pfrom.fFeeler) {
- assert(pfrom.fInbound == false);
+ if (pfrom.IsFeelerConn()) {
pfrom.fDisconnect = true;
}
return;
diff --git a/src/test/net_tests.cpp b/src/test/net_tests.cpp
index 5840f5a72c..34be51d5a2 100644
--- a/src/test/net_tests.cpp
+++ b/src/test/net_tests.cpp
@@ -181,14 +181,11 @@ BOOST_AUTO_TEST_CASE(cnode_simple_test)
CAddress addr = CAddress(CService(ipv4Addr, 7777), NODE_NETWORK);
std::string pszDest;
- // Test that fFeeler is false by default.
std::unique_ptr<CNode> pnode1 = MakeUnique<CNode>(id++, NODE_NETWORK, height, hSocket, addr, 0, 0, CAddress(), pszDest, ConnectionType::OUTBOUND);
BOOST_CHECK(pnode1->fInbound == false);
- BOOST_CHECK(pnode1->fFeeler == false);
std::unique_ptr<CNode> pnode2 = MakeUnique<CNode>(id++, NODE_NETWORK, height, hSocket, addr, 1, 1, CAddress(), pszDest, ConnectionType::INBOUND);
BOOST_CHECK(pnode2->fInbound == true);
- BOOST_CHECK(pnode2->fFeeler == false);
}
// prior to PR #14728, this test triggers an undefined behavior