From 6609eb8cb50fe92c7317b5db9e72d4333b3aab1b Mon Sep 17 00:00:00 2001 From: Jon Atack Date: Wed, 21 Oct 2020 11:52:19 +0200 Subject: [PATCH] net: assert CNode::m_inbound_onion is inbound in ctor and drop an unneeded check in CNode::ConnectedThroughNetwork() --- src/net.cpp | 3 ++- src/net.h | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/net.cpp b/src/net.cpp index b3c521116b5..cf1ac357128 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -555,7 +555,7 @@ void CNode::SetAddrLocal(const CService& addrLocalIn) { Network CNode::ConnectedThroughNetwork() const { - return IsInboundConn() && m_inbound_onion ? NET_ONION : addr.GetNetClass(); + return m_inbound_onion ? NET_ONION : addr.GetNetClass(); } #undef X @@ -2954,6 +2954,7 @@ CNode::CNode(NodeId idIn, ServiceFlags nLocalServicesIn, int nMyStartingHeightIn nMyStartingHeight(nMyStartingHeightIn), m_inbound_onion(inbound_onion) { + if (inbound_onion) assert(conn_type_in == ConnectionType::INBOUND); hSocket = hSocketIn; addrName = addrNameIn == "" ? addr.ToStringIPPort() : addrNameIn; hashContinue = uint256(); diff --git a/src/net.h b/src/net.h index b7c45abb094..ca5944d46b2 100644 --- a/src/net.h +++ b/src/net.h @@ -1110,7 +1110,7 @@ private: CService addrLocal GUARDED_BY(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}; public: