[net/refactor] Remove fFeeler flag from CNode
This commit is contained in:
1 parent
49efac5cae
commit
14923422b0
4 files changed
+10
-12
No files matched your search
+3
-4
@@ -1648,7 +1648,7 @@ void CConnman::ThreadDNSAddressSeed()
|
|||||||
{
|
{
|
||||||
LOCK(cs_vNodes);
|
LOCK(cs_vNodes);
|
||||||
for (const CNode* pnode : 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) {
|
if (nRelevant >= 2) {
|
||||||
@@ -1758,7 +1758,7 @@ int CConnman::GetExtraOutboundCount()
|
|||||||
{
|
{
|
||||||
LOCK(cs_vNodes);
|
LOCK(cs_vNodes);
|
||||||
for (const CNode* pnode : 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;
|
++nOutbound;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1841,7 +1841,7 @@ void CConnman::ThreadOpenConnections(const std::vector<std::string> connect)
|
|||||||
setConnected.insert(pnode->addr.GetGroup(addrman.m_asmap));
|
setConnected.insert(pnode->addr.GetGroup(addrman.m_asmap));
|
||||||
if (pnode->m_tx_relay == nullptr) {
|
if (pnode->m_tx_relay == nullptr) {
|
||||||
nOutboundBlockRelay++;
|
nOutboundBlockRelay++;
|
||||||
} else if (!pnode->fFeeler) {
|
} else if (!pnode->IsFeelerConn()) {
|
||||||
nOutboundFullRelay++;
|
nOutboundFullRelay++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2739,7 +2739,6 @@ CNode::CNode(NodeId idIn, ServiceFlags nLocalServicesIn, int nMyStartingHeightIn
|
|||||||
: nTimeConnected(GetSystemTimeInSeconds()),
|
: nTimeConnected(GetSystemTimeInSeconds()),
|
||||||
addr(addrIn),
|
addr(addrIn),
|
||||||
addrBind(addrBindIn),
|
addrBind(addrBindIn),
|
||||||
fFeeler(conn_type_in == ConnectionType::FEELER),
|
|
||||||
m_addr_fetch(conn_type_in == ConnectionType::ADDR_FETCH),
|
m_addr_fetch(conn_type_in == ConnectionType::ADDR_FETCH),
|
||||||
fInbound(conn_type_in == ConnectionType::INBOUND),
|
fInbound(conn_type_in == ConnectionType::INBOUND),
|
||||||
nKeyedNetGroup(nKeyedNetGroupIn),
|
nKeyedNetGroup(nKeyedNetGroupIn),
|
||||||
|
|||||||
@@ -775,7 +775,6 @@ public:
|
|||||||
}
|
}
|
||||||
// This boolean is unusued in actual processing, only present for backward compatibility at RPC/QT level
|
// This boolean is unusued in actual processing, only present for backward compatibility at RPC/QT level
|
||||||
bool m_legacyWhitelisted{false};
|
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 m_addr_fetch{false};
|
||||||
bool fClient{false}; // set by version message
|
bool fClient{false}; // set by version message
|
||||||
bool m_limited_node{false}; //after BIP159, 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;
|
return m_conn_type == ConnectionType::MANUAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsFeelerConn() const {
|
||||||
|
return m_conn_type == ConnectionType::FEELER;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
mapMsgCmdSize mapSendBytesPerMsgCmd;
|
mapMsgCmdSize mapSendBytesPerMsgCmd;
|
||||||
mapMsgCmdSize mapRecvBytesPerMsgCmd GUARDED_BY(cs_vRecv);
|
mapMsgCmdSize mapRecvBytesPerMsgCmd GUARDED_BY(cs_vRecv);
|
||||||
|
|||||||
@@ -829,7 +829,7 @@ void UpdateLastBlockAnnounceTime(NodeId node, int64_t time_in_seconds)
|
|||||||
|
|
||||||
static bool IsOutboundDisconnectionCandidate(const CNode& node)
|
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) {
|
void PeerLogicValidation::InitializeNode(CNode *pnode) {
|
||||||
@@ -2324,7 +2324,7 @@ void ProcessMessage(
|
|||||||
{
|
{
|
||||||
connman.SetServices(pfrom.addr, nServices);
|
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));
|
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;
|
pfrom.fDisconnect = true;
|
||||||
@@ -2452,8 +2452,7 @@ void ProcessMessage(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Feeler connections exist only to verify if address is online.
|
// Feeler connections exist only to verify if address is online.
|
||||||
if (pfrom.fFeeler) {
|
if (pfrom.IsFeelerConn()) {
|
||||||
assert(pfrom.fInbound == false);
|
|
||||||
pfrom.fDisconnect = true;
|
pfrom.fDisconnect = true;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -181,14 +181,11 @@ BOOST_AUTO_TEST_CASE(cnode_simple_test)
|
|||||||
CAddress addr = CAddress(CService(ipv4Addr, 7777), NODE_NETWORK);
|
CAddress addr = CAddress(CService(ipv4Addr, 7777), NODE_NETWORK);
|
||||||
std::string pszDest;
|
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);
|
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->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);
|
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->fInbound == true);
|
||||||
BOOST_CHECK(pnode2->fFeeler == false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// prior to PR #14728, this test triggers an undefined behavior
|
// prior to PR #14728, this test triggers an undefined behavior
|
||||||
|
|||||||
Reference in new issue
Block a user