0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-02-08 10:31:50 -05:00

[net/refactor] Remove fFeeler flag from CNode

This commit is contained in:
Amiti Uttarwar 2020-05-12 12:58:41 -07:00
parent 49efac5cae
commit 14923422b0
4 changed files with 10 additions and 12 deletions

View file

@ -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),

View file

@ -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);

View file

@ -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;

View file

@ -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