net: assert CNode::m_inbound_onion is inbound in ctor

and drop an unneeded check in CNode::ConnectedThroughNetwork()
This commit is contained in:
Jon Atack 2020-10-21 11:52:19 +02:00
parent 993d1ecd19
commit 6609eb8cb5
No known key found for this signature in database
GPG key ID: 4F5721B3D0E3921D
2 changed files with 3 additions and 2 deletions

View file

@ -555,7 +555,7 @@ void CNode::SetAddrLocal(const CService& addrLocalIn) {
Network CNode::ConnectedThroughNetwork() const Network CNode::ConnectedThroughNetwork() const
{ {
return IsInboundConn() && m_inbound_onion ? NET_ONION : addr.GetNetClass(); return m_inbound_onion ? NET_ONION : addr.GetNetClass();
} }
#undef X #undef X
@ -2954,6 +2954,7 @@ CNode::CNode(NodeId idIn, ServiceFlags nLocalServicesIn, int nMyStartingHeightIn
nMyStartingHeight(nMyStartingHeightIn), nMyStartingHeight(nMyStartingHeightIn),
m_inbound_onion(inbound_onion) m_inbound_onion(inbound_onion)
{ {
if (inbound_onion) assert(conn_type_in == ConnectionType::INBOUND);
hSocket = hSocketIn; hSocket = hSocketIn;
addrName = addrNameIn == "" ? addr.ToStringIPPort() : addrNameIn; addrName = addrNameIn == "" ? addr.ToStringIPPort() : addrNameIn;
hashContinue = uint256(); hashContinue = uint256();

View file

@ -1110,7 +1110,7 @@ private:
CService addrLocal GUARDED_BY(cs_addrLocal); CService addrLocal GUARDED_BY(cs_addrLocal);
mutable RecursiveMutex cs_addrLocal; mutable RecursiveMutex cs_addrLocal;
//! Whether this peer connected via our Tor onion service. //! Whether this peer is an inbound onion, e.g. connected via our Tor onion service.
const bool m_inbound_onion{false}; const bool m_inbound_onion{false};
public: public: