Dash Core  0.12.2.1
P2P Digital Currency
CConnman Class Reference

#include <net.h>

Classes

struct  CAllNodes
 
struct  CFullyConnectedOnly
 
struct  ListenSocket
 
struct  Options
 

Public Types

enum  NumConnections { CONNECTIONS_NONE = 0, CONNECTIONS_IN = (1U << 0), CONNECTIONS_OUT = (1U << 1), CONNECTIONS_ALL = (CONNECTIONS_IN | CONNECTIONS_OUT) }
 

Public Member Functions

 CConnman ()
 
 ~CConnman ()
 
bool Start (CScheduler &scheduler, std::string &strNodeError, Options options)
 
void Stop ()
 
void Interrupt ()
 
bool BindListenPort (const CService &bindAddr, std::string &strError, bool fWhitelisted=false)
 
bool GetNetworkActive () const
 
void SetNetworkActive (bool active)
 
bool OpenNetworkConnection (const CAddress &addrConnect, CSemaphoreGrant *grantOutbound=NULL, const char *strDest=NULL, bool fOneShot=false, bool fFeeler=false)
 
bool CheckIncomingNonce (uint64_t nonce)
 
CNodeConnectNode (CAddress addrConnect, const char *pszDest=NULL, bool fConnectToMasternode=false)
 
bool ForNode (NodeId id, std::function< bool(const CNode *pnode)> cond, std::function< bool(CNode *pnode)> func)
 
bool ForNode (const CService &addr, std::function< bool(const CNode *pnode)> cond, std::function< bool(CNode *pnode)> func)
 
template<typename Callable >
bool ForNode (const CService &addr, Callable &&func)
 
template<typename Callable >
bool ForNode (NodeId id, Callable &&func)
 
template<typename... Args>
void PushMessageWithVersionAndFlag (CNode *pnode, int nVersion, int flag, const std::string &sCommand, Args &&... args)
 
template<typename... Args>
void PushMessageWithFlag (CNode *pnode, int flag, const std::string &sCommand, Args &&... args)
 
template<typename... Args>
void PushMessageWithVersion (CNode *pnode, int nVersion, const std::string &sCommand, Args &&... args)
 
template<typename... Args>
void PushMessage (CNode *pnode, const std::string &sCommand, Args &&... args)
 
template<typename Condition , typename Callable >
bool ForEachNodeContinueIf (const Condition &cond, Callable &&func)
 
template<typename Callable >
bool ForEachNodeContinueIf (Callable &&func)
 
template<typename Condition , typename Callable >
bool ForEachNodeContinueIf (const Condition &cond, Callable &&func) const
 
template<typename Callable >
bool ForEachNodeContinueIf (Callable &&func) const
 
template<typename Condition , typename Callable >
void ForEachNode (const Condition &cond, Callable &&func)
 
template<typename Callable >
void ForEachNode (Callable &&func)
 
template<typename Condition , typename Callable >
void ForEachNode (const Condition &cond, Callable &&func) const
 
template<typename Callable >
void ForEachNode (Callable &&func) const
 
template<typename Condition , typename Callable , typename CallableAfter >
void ForEachNodeThen (const Condition &cond, Callable &&pre, CallableAfter &&post)
 
template<typename Callable , typename CallableAfter >
void ForEachNodeThen (Callable &&pre, CallableAfter &&post)
 
template<typename Condition , typename Callable , typename CallableAfter >
void ForEachNodeThen (const Condition &cond, Callable &&pre, CallableAfter &&post) const
 
template<typename Callable , typename CallableAfter >
void ForEachNodeThen (Callable &&pre, CallableAfter &&post) const
 
std::vector< CNode * > CopyNodeVector ()
 
void ReleaseNodeVector (const std::vector< CNode *> &vecNodes)
 
void RelayTransaction (const CTransaction &tx)
 
void RelayTransaction (const CTransaction &tx, const CDataStream &ss)
 
void RelayInv (CInv &inv, const int minProtoVersion=MIN_PEER_PROTO_VERSION)
 
size_t GetAddressCount () const
 
void SetServices (const CService &addr, ServiceFlags nServices)
 
void MarkAddressGood (const CAddress &addr)
 
void AddNewAddress (const CAddress &addr, const CAddress &addrFrom, int64_t nTimePenalty=0)
 
void AddNewAddresses (const std::vector< CAddress > &vAddr, const CAddress &addrFrom, int64_t nTimePenalty=0)
 
std::vector< CAddressGetAddresses ()
 
void AddressCurrentlyConnected (const CService &addr)
 
void Ban (const CNetAddr &netAddr, const BanReason &reason, int64_t bantimeoffset=0, bool sinceUnixEpoch=false)
 
void Ban (const CSubNet &subNet, const BanReason &reason, int64_t bantimeoffset=0, bool sinceUnixEpoch=false)
 
void ClearBanned ()
 
bool IsBanned (CNetAddr ip)
 
bool IsBanned (CSubNet subnet)
 
bool Unban (const CNetAddr &ip)
 
bool Unban (const CSubNet &ip)
 
void GetBanned (banmap_t &banmap)
 
void SetBanned (const banmap_t &banmap)
 
void AddOneShot (const std::string &strDest)
 
bool AddNode (const std::string &node)
 
bool RemoveAddedNode (const std::string &node)
 
std::vector< AddedNodeInfoGetAddedNodeInfo ()
 
size_t GetNodeCount (NumConnections num)
 
void GetNodeStats (std::vector< CNodeStats > &vstats)
 
bool DisconnectNode (const std::string &node)
 
bool DisconnectNode (NodeId id)
 
unsigned int GetSendBufferSize () const
 
void AddWhitelistedRange (const CSubNet &subnet)
 
ServiceFlags GetLocalServices () const
 
void SetMaxOutboundTarget (uint64_t limit)
 set the max outbound target in bytes More...
 
uint64_t GetMaxOutboundTarget ()
 
void SetMaxOutboundTimeframe (uint64_t timeframe)
 set the timeframe for the max outbound target More...
 
uint64_t GetMaxOutboundTimeframe ()
 
bool OutboundTargetReached (bool historicalBlockServingLimit)
 check if the outbound target is reached More...
 
uint64_t GetOutboundTargetBytesLeft ()
 response the bytes left in the current max outbound cycle More...
 
uint64_t GetMaxOutboundTimeLeftInCycle ()
 response the time in second left in the current max outbound cycle More...
 
uint64_t GetTotalBytesRecv ()
 
uint64_t GetTotalBytesSent ()
 
void SetBestHeight (int height)
 
int GetBestHeight () const
 
unsigned int GetReceiveFloodSize () const
 

Static Public Attributes

static constexpr const CFullyConnectedOnly FullyConnectedOnly {}
 
static constexpr const CAllNodes AllNodes {}
 

Private Member Functions

void ThreadOpenAddedConnections ()
 
void ProcessOneShot ()
 
void ThreadOpenConnections ()
 
void ThreadMessageHandler ()
 
void AcceptConnection (const ListenSocket &hListenSocket)
 
void ThreadSocketHandler ()
 
void ThreadDNSAddressSeed ()
 
void ThreadMnbRequestConnections ()
 
void WakeMessageHandler ()
 
CNodeFindNode (const CNetAddr &ip)
 
CNodeFindNode (const CSubNet &subNet)
 
CNodeFindNode (const std::string &addrName)
 
CNodeFindNode (const CService &addr)
 
bool AttemptToEvictConnection ()
 
bool IsWhitelistedRange (const CNetAddr &addr)
 
void DeleteNode (CNode *pnode)
 
NodeId GetNewNodeId ()
 
size_t SocketSendData (CNode *pnode)
 
bool BannedSetIsDirty ()
 check is the banlist has unwritten changes More...
 
void SetBannedSetDirty (bool dirty=true)
 set the "dirty" flag for the banlist More...
 
void SweepBanned ()
 clean unused entries (if bantime has expired) More...
 
void DumpAddresses ()
 
void DumpData ()
 
void DumpBanlist ()
 
CDataStream BeginMessage (CNode *node, int nVersion, int flags, const std::string &sCommand)
 
void PushMessage (CNode *pnode, CDataStream &strm, const std::string &sCommand)
 
void EndMessage (CDataStream &strm)
 
void RecordBytesRecv (uint64_t bytes)
 
void RecordBytesSent (uint64_t bytes)
 

Static Private Member Functions

static bool NodeFullyConnected (const CNode *pnode)
 

Private Attributes

CCriticalSection cs_totalBytesRecv
 
CCriticalSection cs_totalBytesSent
 
uint64_t nTotalBytesRecv
 
uint64_t nTotalBytesSent
 
uint64_t nMaxOutboundTotalBytesSentInCycle
 
uint64_t nMaxOutboundCycleStartTime
 
uint64_t nMaxOutboundLimit
 
uint64_t nMaxOutboundTimeframe
 
std::vector< CSubNetvWhitelistedRange
 
CCriticalSection cs_vWhitelistedRange
 
unsigned int nSendBufferMaxSize
 
unsigned int nReceiveFloodSize
 
std::vector< ListenSocketvhListenSocket
 
bool fNetworkActive
 
banmap_t setBanned
 
CCriticalSection cs_setBanned
 
bool setBannedIsDirty
 
bool fAddressesInitialized
 
CAddrMan addrman
 
std::deque< std::string > vOneShots
 
CCriticalSection cs_vOneShots
 
std::vector< std::string > vAddedNodes
 
CCriticalSection cs_vAddedNodes
 
std::vector< CNode * > vNodes
 
std::list< CNode * > vNodesDisconnected
 
CCriticalSection cs_vNodes
 
std::atomic< NodeIdnLastNodeId
 
ServiceFlags nLocalServices
 
ServiceFlags nRelevantServices
 
CSemaphoresemOutbound
 
CSemaphoresemMasternodeOutbound
 
int nMaxConnections
 
int nMaxOutbound
 
int nMaxFeeler
 
std::atomic< int > nBestHeight
 
CClientUIInterfaceclientInterface
 
bool fMsgProcWake
 
std::condition_variable condMsgProc
 
std::mutex mutexMsgProc
 
std::atomic< bool > flagInterruptMsgProc
 
CThreadInterrupt interruptNet
 
std::thread threadDNSAddressSeed
 
std::thread threadSocketHandler
 
std::thread threadOpenAddedConnections
 
std::thread threadOpenConnections
 
std::thread threadMnbRequestConnections
 
std::thread threadMessageHandler
 

Detailed Description

Definition at line 108 of file net.h.

Member Enumeration Documentation

◆ NumConnections

Enumerator
CONNECTIONS_NONE 
CONNECTIONS_IN 
CONNECTIONS_OUT 
CONNECTIONS_ALL 

Definition at line 112 of file net.h.

Constructor & Destructor Documentation

◆ CConnman()

CConnman::CConnman ( )

Definition at line 2134 of file net.cpp.

◆ ~CConnman()

CConnman::~CConnman ( )

Definition at line 2369 of file net.cpp.

Member Function Documentation

◆ AcceptConnection()

void CConnman::AcceptConnection ( const ListenSocket hListenSocket)
private

Definition at line 1023 of file net.cpp.

Referenced by ThreadSocketHandler().

◆ AddNewAddress()

void CConnman::AddNewAddress ( const CAddress addr,
const CAddress addrFrom,
int64_t  nTimePenalty = 0 
)

Definition at line 2390 of file net.cpp.

Referenced by CMasternodeMan::ProcessMessage().

◆ AddNewAddresses()

void CConnman::AddNewAddresses ( const std::vector< CAddress > &  vAddr,
const CAddress addrFrom,
int64_t  nTimePenalty = 0 
)

Definition at line 2395 of file net.cpp.

Referenced by ProcessMessage().

◆ AddNode()

bool CConnman::AddNode ( const std::string &  node)

Definition at line 2405 of file net.cpp.

◆ AddOneShot()

void CConnman::AddOneShot ( const std::string &  strDest)

Definition at line 94 of file net.cpp.

Referenced by ProcessOneShot(), and ThreadDNSAddressSeed().

◆ AddressCurrentlyConnected()

void CConnman::AddressCurrentlyConnected ( const CService addr)

◆ AddWhitelistedRange()

void CConnman::AddWhitelistedRange ( const CSubNet subnet)

Definition at line 628 of file net.cpp.

◆ AttemptToEvictConnection()

bool CConnman::AttemptToEvictConnection ( )
private

Try to find a connection to evict when the node is full. Extreme care must be taken to avoid opening the node to attacker triggered network partitioning. The strategy used here is to protect a small number of peers for each of several distinct characteristics which are difficult to forge. In order to partition a node the attacker must be simultaneously better at all of them than honest peers.

Definition at line 924 of file net.cpp.

Referenced by AcceptConnection().

◆ Ban() [1/2]

void CConnman::Ban ( const CNetAddr netAddr,
const BanReason reason,
int64_t  bantimeoffset = 0,
bool  sinceUnixEpoch = false 
)

Definition at line 517 of file net.cpp.

Referenced by SendMessages().

◆ Ban() [2/2]

void CConnman::Ban ( const CSubNet subNet,
const BanReason reason,
int64_t  bantimeoffset = 0,
bool  sinceUnixEpoch = false 
)

Definition at line 522 of file net.cpp.

◆ BannedSetIsDirty()

bool CConnman::BannedSetIsDirty ( )
private

check is the banlist has unwritten changes

Definition at line 606 of file net.cpp.

Referenced by DumpBanlist().

◆ BeginMessage()

CDataStream CConnman::BeginMessage ( CNode node,
int  nVersion,
int  flags,
const std::string &  sCommand 
)
private

Definition at line 2817 of file net.cpp.

Referenced by PushMessageWithVersionAndFlag().

◆ BindListenPort()

bool CConnman::BindListenPort ( const CService bindAddr,
std::string &  strError,
bool  fWhitelisted = false 
)

Definition at line 1964 of file net.cpp.

Referenced by Bind().

◆ CheckIncomingNonce()

bool CConnman::CheckIncomingNonce ( uint64_t  nonce)

Definition at line 337 of file net.cpp.

Referenced by ProcessMessage().

◆ ClearBanned()

void CConnman::ClearBanned ( )

Definition at line 472 of file net.cpp.

◆ ConnectNode()

CNode * CConnman::ConnectNode ( CAddress  addrConnect,
const char *  pszDest = NULL,
bool  fConnectToMasternode = false 
)

◆ CopyNodeVector()

std::vector< CNode * > CConnman::CopyNodeVector ( )

◆ DeleteNode()

void CConnman::DeleteNode ( CNode pnode)
private

Definition at line 2359 of file net.cpp.

Referenced by Stop(), and ThreadSocketHandler().

◆ DisconnectNode() [1/2]

bool CConnman::DisconnectNode ( const std::string &  node)

Definition at line 2456 of file net.cpp.

◆ DisconnectNode() [2/2]

bool CConnman::DisconnectNode ( NodeId  id)

Definition at line 2465 of file net.cpp.

◆ DumpAddresses()

void CConnman::DumpAddresses ( )
private

Definition at line 1585 of file net.cpp.

Referenced by DumpData(), and Start().

◆ DumpBanlist()

void CConnman::DumpBanlist ( )
private

Definition at line 442 of file net.cpp.

Referenced by Ban(), ClearBanned(), DumpData(), Start(), and Unban().

◆ DumpData()

void CConnman::DumpData ( )
private

Definition at line 1596 of file net.cpp.

Referenced by Start(), and Stop().

◆ EndMessage()

void CConnman::EndMessage ( CDataStream strm)
private

Definition at line 2822 of file net.cpp.

Referenced by PushMessageWithVersionAndFlag().

◆ FindNode() [1/4]

CNode * CConnman::FindNode ( const CNetAddr ip)
private

◆ FindNode() [2/4]

CNode * CConnman::FindNode ( const CSubNet subNet)
private

Definition at line 310 of file net.cpp.

◆ FindNode() [3/4]

CNode * CConnman::FindNode ( const std::string &  addrName)
private

Definition at line 319 of file net.cpp.

◆ FindNode() [4/4]

CNode * CConnman::FindNode ( const CService addr)
private

Definition at line 328 of file net.cpp.

◆ ForEachNode() [1/4]

template<typename Condition , typename Callable >
void CConnman::ForEachNode ( const Condition &  cond,
Callable &&  func 
)
inline

◆ ForEachNode() [2/4]

template<typename Callable >
void CConnman::ForEachNode ( Callable &&  func)
inline

Definition at line 249 of file net.h.

◆ ForEachNode() [3/4]

template<typename Condition , typename Callable >
void CConnman::ForEachNode ( const Condition &  cond,
Callable &&  func 
) const
inline

Definition at line 255 of file net.h.

◆ ForEachNode() [4/4]

template<typename Callable >
void CConnman::ForEachNode ( Callable &&  func) const
inline

Definition at line 265 of file net.h.

◆ ForEachNodeContinueIf() [1/4]

template<typename Condition , typename Callable >
bool CConnman::ForEachNodeContinueIf ( const Condition &  cond,
Callable &&  func 
)
inline

Definition at line 205 of file net.h.

Referenced by ForEachNodeContinueIf(), and CActiveMasternode::ManageStateInitial().

◆ ForEachNodeContinueIf() [2/4]

template<typename Callable >
bool CConnman::ForEachNodeContinueIf ( Callable &&  func)
inline

Definition at line 216 of file net.h.

◆ ForEachNodeContinueIf() [3/4]

template<typename Condition , typename Callable >
bool CConnman::ForEachNodeContinueIf ( const Condition &  cond,
Callable &&  func 
) const
inline

Definition at line 222 of file net.h.

◆ ForEachNodeContinueIf() [4/4]

template<typename Callable >
bool CConnman::ForEachNodeContinueIf ( Callable &&  func) const
inline

Definition at line 233 of file net.h.

◆ ForEachNodeThen() [1/4]

template<typename Condition , typename Callable , typename CallableAfter >
void CConnman::ForEachNodeThen ( const Condition &  cond,
Callable &&  pre,
CallableAfter &&  post 
)
inline

Definition at line 271 of file net.h.

Referenced by ForEachNodeThen(), and RelayAddress().

◆ ForEachNodeThen() [2/4]

template<typename Callable , typename CallableAfter >
void CConnman::ForEachNodeThen ( Callable &&  pre,
CallableAfter &&  post 
)
inline

Definition at line 282 of file net.h.

◆ ForEachNodeThen() [3/4]

template<typename Condition , typename Callable , typename CallableAfter >
void CConnman::ForEachNodeThen ( const Condition &  cond,
Callable &&  pre,
CallableAfter &&  post 
) const
inline

Definition at line 288 of file net.h.

◆ ForEachNodeThen() [4/4]

template<typename Callable , typename CallableAfter >
void CConnman::ForEachNodeThen ( Callable &&  pre,
CallableAfter &&  post 
) const
inline

Definition at line 299 of file net.h.

◆ ForNode() [1/4]

bool CConnman::ForNode ( NodeId  id,
std::function< bool(const CNode *pnode)>  cond,
std::function< bool(CNode *pnode)>  func 
)

◆ ForNode() [2/4]

bool CConnman::ForNode ( const CService addr,
std::function< bool(const CNode *pnode)>  cond,
std::function< bool(CNode *pnode)>  func 
)

Definition at line 2866 of file net.cpp.

◆ ForNode() [3/4]

template<typename Callable >
bool CConnman::ForNode ( const CService addr,
Callable &&  func 
)
inline

Definition at line 166 of file net.h.

◆ ForNode() [4/4]

template<typename Callable >
bool CConnman::ForNode ( NodeId  id,
Callable &&  func 
)
inline

Definition at line 172 of file net.h.

◆ GetAddedNodeInfo()

std::vector< AddedNodeInfo > CConnman::GetAddedNodeInfo ( )

Definition at line 1764 of file net.cpp.

Referenced by ThreadOpenAddedConnections().

◆ GetAddressCount()

size_t CConnman::GetAddressCount ( ) const

Definition at line 2375 of file net.cpp.

Referenced by ProcessMessage().

◆ GetAddresses()

std::vector< CAddress > CConnman::GetAddresses ( )

Definition at line 2400 of file net.cpp.

Referenced by ProcessMessage().

◆ GetBanned()

void CConnman::GetBanned ( banmap_t banmap)

Definition at line 572 of file net.cpp.

Referenced by DumpBanlist().

◆ GetBestHeight()

int CConnman::GetBestHeight ( ) const

Definition at line 2657 of file net.cpp.

Referenced by AcceptConnection(), ConnectNode(), and Start().

◆ GetLocalServices()

ServiceFlags CConnman::GetLocalServices ( ) const

Definition at line 2647 of file net.cpp.

◆ GetMaxOutboundTarget()

uint64_t CConnman::GetMaxOutboundTarget ( )

Definition at line 2568 of file net.cpp.

◆ GetMaxOutboundTimeframe()

uint64_t CConnman::GetMaxOutboundTimeframe ( )

Definition at line 2574 of file net.cpp.

◆ GetMaxOutboundTimeLeftInCycle()

uint64_t CConnman::GetMaxOutboundTimeLeftInCycle ( )

response the time in second left in the current max outbound cycle

Definition at line 2580 of file net.cpp.

Referenced by OutboundTargetReached().

◆ GetNetworkActive()

bool CConnman::GetNetworkActive ( ) const
inline

Definition at line 137 of file net.h.

◆ GetNewNodeId()

NodeId CConnman::GetNewNodeId ( )
private

Definition at line 2151 of file net.cpp.

Referenced by AcceptConnection(), ConnectNode(), and Start().

◆ GetNodeCount()

size_t CConnman::GetNodeCount ( NumConnections  num)

Definition at line 2429 of file net.cpp.

Referenced by BitcoinMiner(), and ThreadSendAlert().

◆ GetNodeStats()

void CConnman::GetNodeStats ( std::vector< CNodeStats > &  vstats)

Definition at line 2443 of file net.cpp.

◆ GetOutboundTargetBytesLeft()

uint64_t CConnman::GetOutboundTargetBytesLeft ( )

response the bytes left in the current max outbound cycle

Definition at line 2626 of file net.cpp.

◆ GetReceiveFloodSize()

unsigned int CConnman::GetReceiveFloodSize ( ) const

Definition at line 2662 of file net.cpp.

Referenced by ProcessMessages().

◆ GetSendBufferSize()

unsigned int CConnman::GetSendBufferSize ( ) const

Definition at line 2663 of file net.cpp.

◆ GetTotalBytesRecv()

uint64_t CConnman::GetTotalBytesRecv ( )

Definition at line 2635 of file net.cpp.

◆ GetTotalBytesSent()

uint64_t CConnman::GetTotalBytesSent ( )

Definition at line 2641 of file net.cpp.

◆ Interrupt()

void CConnman::Interrupt ( )

Definition at line 2290 of file net.cpp.

Referenced by ~CConnman().

◆ IsBanned() [1/2]

bool CConnman::IsBanned ( CNetAddr  ip)

Definition at line 484 of file net.cpp.

Referenced by AcceptConnection(), and OpenNetworkConnection().

◆ IsBanned() [2/2]

bool CConnman::IsBanned ( CSubNet  subnet)

Definition at line 501 of file net.cpp.

◆ IsWhitelistedRange()

bool CConnman::IsWhitelistedRange ( const CNetAddr addr)
private

Definition at line 619 of file net.cpp.

Referenced by AcceptConnection().

◆ MarkAddressGood()

void CConnman::MarkAddressGood ( const CAddress addr)

Definition at line 2385 of file net.cpp.

Referenced by ProcessMessage().

◆ NodeFullyConnected()

bool CConnman::NodeFullyConnected ( const CNode pnode)
staticprivate

Definition at line 2791 of file net.cpp.

Referenced by CConnman::CFullyConnectedOnly::operator()().

◆ OpenNetworkConnection()

bool CConnman::OpenNetworkConnection ( const CAddress addrConnect,
CSemaphoreGrant grantOutbound = NULL,
const char *  strDest = NULL,
bool  fOneShot = false,
bool  fFeeler = false 
)

Definition at line 1886 of file net.cpp.

Referenced by ProcessOneShot(), ThreadOpenAddedConnections(), and ThreadOpenConnections().

◆ OutboundTargetReached()

bool CConnman::OutboundTargetReached ( bool  historicalBlockServingLimit)

check if the outbound target is reached

Definition at line 2606 of file net.cpp.

Referenced by ProcessGetData(), and ProcessMessage().

◆ ProcessOneShot()

void CConnman::ProcessOneShot ( )
private

Definition at line 1602 of file net.cpp.

Referenced by ThreadOpenConnections().

◆ PushMessage() [1/2]

◆ PushMessage() [2/2]

void CConnman::PushMessage ( CNode pnode,
CDataStream strm,
const std::string &  sCommand 
)
private

Definition at line 2834 of file net.cpp.

◆ PushMessageWithFlag()

template<typename... Args>
void CConnman::PushMessageWithFlag ( CNode pnode,
int  flag,
const std::string &  sCommand,
Args &&...  args 
)
inline

Definition at line 187 of file net.h.

◆ PushMessageWithVersion()

template<typename... Args>
void CConnman::PushMessageWithVersion ( CNode pnode,
int  nVersion,
const std::string &  sCommand,
Args &&...  args 
)
inline

Definition at line 193 of file net.h.

Referenced by ProcessMessage(), ProcessMessages(), and CMasternodeSync::ProcessTick().

◆ PushMessageWithVersionAndFlag()

template<typename... Args>
void CConnman::PushMessageWithVersionAndFlag ( CNode pnode,
int  nVersion,
int  flag,
const std::string &  sCommand,
Args &&...  args 
)
inline

Definition at line 178 of file net.h.

Referenced by PushMessage(), PushMessageWithFlag(), and PushMessageWithVersion().

◆ RecordBytesRecv()

void CConnman::RecordBytesRecv ( uint64_t  bytes)
private

Definition at line 2535 of file net.cpp.

Referenced by ThreadSocketHandler().

◆ RecordBytesSent()

void CConnman::RecordBytesSent ( uint64_t  bytes)
private

Definition at line 2541 of file net.cpp.

Referenced by PushMessage(), and ThreadSocketHandler().

◆ RelayInv()

◆ RelayTransaction() [1/2]

◆ RelayTransaction() [2/2]

void CConnman::RelayTransaction ( const CTransaction tx,
const CDataStream ss 
)

Definition at line 2494 of file net.cpp.

◆ ReleaseNodeVector()

void CConnman::ReleaseNodeVector ( const std::vector< CNode *> &  vecNodes)

◆ RemoveAddedNode()

bool CConnman::RemoveAddedNode ( const std::string &  node)

Definition at line 2417 of file net.cpp.

◆ SetBanned()

void CConnman::SetBanned ( const banmap_t banmap)

Definition at line 578 of file net.cpp.

Referenced by Start().

◆ SetBannedSetDirty()

void CConnman::SetBannedSetDirty ( bool  dirty = true)
private

set the "dirty" flag for the banlist

Definition at line 612 of file net.cpp.

Referenced by DumpBanlist(), and Start().

◆ SetBestHeight()

void CConnman::SetBestHeight ( int  height)

Definition at line 2652 of file net.cpp.

Referenced by Start(), and PeerLogicValidation::UpdatedBlockTip().

◆ SetMaxOutboundTarget()

void CConnman::SetMaxOutboundTarget ( uint64_t  limit)

set the max outbound target in bytes

Definition at line 2558 of file net.cpp.

◆ SetMaxOutboundTimeframe()

void CConnman::SetMaxOutboundTimeframe ( uint64_t  timeframe)

set the timeframe for the max outbound target

Definition at line 2594 of file net.cpp.

◆ SetNetworkActive()

void CConnman::SetNetworkActive ( bool  active)

Definition at line 2113 of file net.cpp.

◆ SetServices()

void CConnman::SetServices ( const CService addr,
ServiceFlags  nServices 
)

Definition at line 2380 of file net.cpp.

Referenced by ProcessMessage().

◆ SocketSendData()

size_t CConnman::SocketSendData ( CNode pnode)
private

Definition at line 811 of file net.cpp.

Referenced by PushMessage(), and ThreadSocketHandler().

◆ Start()

bool CConnman::Start ( CScheduler scheduler,
std::string &  strNodeError,
Options  options 
)

Definition at line 2156 of file net.cpp.

◆ Stop()

void CConnman::Stop ( )

Definition at line 2306 of file net.cpp.

Referenced by ~CConnman().

◆ SweepBanned()

void CConnman::SweepBanned ( )
private

clean unused entries (if bantime has expired)

Definition at line 585 of file net.cpp.

Referenced by DumpBanlist(), and Start().

◆ ThreadDNSAddressSeed()

void CConnman::ThreadDNSAddressSeed ( )
private

Definition at line 1522 of file net.cpp.

Referenced by Start().

◆ ThreadMessageHandler()

void CConnman::ThreadMessageHandler ( )
private

Definition at line 1919 of file net.cpp.

Referenced by Start().

◆ ThreadMnbRequestConnections()

void CConnman::ThreadMnbRequestConnections ( )
private

Definition at line 1842 of file net.cpp.

Referenced by Start().

◆ ThreadOpenAddedConnections()

void CConnman::ThreadOpenAddedConnections ( )
private

Definition at line 1816 of file net.cpp.

Referenced by Start().

◆ ThreadOpenConnections()

void CConnman::ThreadOpenConnections ( )
private

Definition at line 1620 of file net.cpp.

Referenced by Start().

◆ ThreadSocketHandler()

void CConnman::ThreadSocketHandler ( )
private

Definition at line 1109 of file net.cpp.

Referenced by Start().

◆ Unban() [1/2]

bool CConnman::Unban ( const CNetAddr ip)

Definition at line 554 of file net.cpp.

◆ Unban() [2/2]

bool CConnman::Unban ( const CSubNet ip)

Definition at line 559 of file net.cpp.

◆ WakeMessageHandler()

void CConnman::WakeMessageHandler ( )
private

Definition at line 1387 of file net.cpp.

Referenced by ThreadSocketHandler().

Member Data Documentation

◆ addrman

◆ AllNodes

◆ clientInterface

CClientUIInterface* CConnman::clientInterface
private

Definition at line 491 of file net.h.

Referenced by Ban(), CConnman(), ClearBanned(), Start(), ThreadSocketHandler(), and Unban().

◆ condMsgProc

std::condition_variable CConnman::condMsgProc
private

Definition at line 496 of file net.h.

Referenced by Interrupt(), ThreadMessageHandler(), and WakeMessageHandler().

◆ cs_setBanned

CCriticalSection CConnman::cs_setBanned
private

◆ cs_totalBytesRecv

CCriticalSection CConnman::cs_totalBytesRecv
private

Definition at line 444 of file net.h.

Referenced by GetTotalBytesRecv(), and RecordBytesRecv().

◆ cs_totalBytesSent

◆ cs_vAddedNodes

CCriticalSection CConnman::cs_vAddedNodes
private

Definition at line 473 of file net.h.

Referenced by AddNode(), GetAddedNodeInfo(), RemoveAddedNode(), and ThreadOpenAddedConnections().

◆ cs_vNodes

◆ cs_vOneShots

CCriticalSection CConnman::cs_vOneShots
private

Definition at line 471 of file net.h.

Referenced by AddOneShot(), and ProcessOneShot().

◆ cs_vWhitelistedRange

CCriticalSection CConnman::cs_vWhitelistedRange
private

Definition at line 458 of file net.h.

Referenced by AddWhitelistedRange(), and IsWhitelistedRange().

◆ fAddressesInitialized

bool CConnman::fAddressesInitialized
private

Definition at line 468 of file net.h.

Referenced by CConnman(), Start(), and Stop().

◆ flagInterruptMsgProc

std::atomic<bool> CConnman::flagInterruptMsgProc
private

Definition at line 498 of file net.h.

Referenced by CConnman(), Interrupt(), Start(), and ThreadMessageHandler().

◆ fMsgProcWake

bool CConnman::fMsgProcWake
private

flag for waking the message processor.

Definition at line 494 of file net.h.

Referenced by Start(), ThreadMessageHandler(), and WakeMessageHandler().

◆ fNetworkActive

bool CConnman::fNetworkActive
private

◆ FullyConnectedOnly

constexpr const CConnman::CFullyConnectedOnly CConnman::FullyConnectedOnly {}
static

Definition at line 154 of file net.h.

Referenced by ForEachNode(), ForEachNodeContinueIf(), ForEachNodeThen(), and ForNode().

◆ interruptNet

◆ mutexMsgProc

std::mutex CConnman::mutexMsgProc
private

Definition at line 497 of file net.h.

Referenced by Interrupt(), Start(), ThreadMessageHandler(), and WakeMessageHandler().

◆ nBestHeight

std::atomic<int> CConnman::nBestHeight
private

Definition at line 490 of file net.h.

Referenced by CConnman(), GetBestHeight(), and SetBestHeight().

◆ nLastNodeId

std::atomic<NodeId> CConnman::nLastNodeId
private

Definition at line 477 of file net.h.

Referenced by CConnman(), and GetNewNodeId().

◆ nLocalServices

ServiceFlags CConnman::nLocalServices
private

Services this instance offers

Definition at line 480 of file net.h.

Referenced by AcceptConnection(), ConnectNode(), GetLocalServices(), and Start().

◆ nMaxConnections

int CConnman::nMaxConnections
private

Definition at line 487 of file net.h.

Referenced by AcceptConnection(), CConnman(), and Start().

◆ nMaxFeeler

int CConnman::nMaxFeeler
private

Definition at line 489 of file net.h.

Referenced by AcceptConnection(), Interrupt(), and Start().

◆ nMaxOutbound

int CConnman::nMaxOutbound
private

Definition at line 488 of file net.h.

Referenced by AcceptConnection(), CConnman(), Interrupt(), Start(), and ThreadOpenConnections().

◆ nMaxOutboundCycleStartTime

uint64_t CConnman::nMaxOutboundCycleStartTime
private

◆ nMaxOutboundLimit

uint64_t CConnman::nMaxOutboundLimit
private

◆ nMaxOutboundTimeframe

uint64_t CConnman::nMaxOutboundTimeframe
private

◆ nMaxOutboundTotalBytesSentInCycle

uint64_t CConnman::nMaxOutboundTotalBytesSentInCycle
private

Definition at line 450 of file net.h.

Referenced by GetOutboundTargetBytesLeft(), OutboundTargetReached(), RecordBytesSent(), and Start().

◆ nReceiveFloodSize

unsigned int CConnman::nReceiveFloodSize
private

Definition at line 461 of file net.h.

Referenced by CConnman(), GetReceiveFloodSize(), Start(), and ThreadSocketHandler().

◆ nRelevantServices

ServiceFlags CConnman::nRelevantServices
private

Services this instance cares about

Definition at line 483 of file net.h.

Referenced by ConnectNode(), and Start().

◆ nSendBufferMaxSize

unsigned int CConnman::nSendBufferMaxSize
private

Definition at line 460 of file net.h.

Referenced by CConnman(), GetSendBufferSize(), PushMessage(), SocketSendData(), and Start().

◆ nTotalBytesRecv

uint64_t CConnman::nTotalBytesRecv
private

Definition at line 446 of file net.h.

Referenced by GetTotalBytesRecv(), RecordBytesRecv(), and Start().

◆ nTotalBytesSent

uint64_t CConnman::nTotalBytesSent
private

Definition at line 447 of file net.h.

Referenced by GetTotalBytesSent(), RecordBytesSent(), and Start().

◆ semMasternodeOutbound

CSemaphore* CConnman::semMasternodeOutbound
private

Definition at line 486 of file net.h.

Referenced by CConnman(), Start(), Stop(), and ThreadMnbRequestConnections().

◆ semOutbound

CSemaphore* CConnman::semOutbound
private

◆ setBanned

banmap_t CConnman::setBanned
private

Definition at line 465 of file net.h.

Referenced by Ban(), ClearBanned(), GetBanned(), IsBanned(), SetBanned(), SweepBanned(), and Unban().

◆ setBannedIsDirty

bool CConnman::setBannedIsDirty
private

◆ threadDNSAddressSeed

std::thread CConnman::threadDNSAddressSeed
private

Definition at line 502 of file net.h.

Referenced by Start(), and Stop().

◆ threadMessageHandler

std::thread CConnman::threadMessageHandler
private

Definition at line 507 of file net.h.

Referenced by Start(), and Stop().

◆ threadMnbRequestConnections

std::thread CConnman::threadMnbRequestConnections
private

Definition at line 506 of file net.h.

Referenced by Start(), and Stop().

◆ threadOpenAddedConnections

std::thread CConnman::threadOpenAddedConnections
private

Definition at line 504 of file net.h.

Referenced by Start(), and Stop().

◆ threadOpenConnections

std::thread CConnman::threadOpenConnections
private

Definition at line 505 of file net.h.

Referenced by Start(), and Stop().

◆ threadSocketHandler

std::thread CConnman::threadSocketHandler
private

Definition at line 503 of file net.h.

Referenced by Start(), and Stop().

◆ vAddedNodes

std::vector<std::string> CConnman::vAddedNodes
private

Definition at line 472 of file net.h.

Referenced by AddNode(), GetAddedNodeInfo(), RemoveAddedNode(), and ThreadOpenAddedConnections().

◆ vhListenSocket

std::vector<ListenSocket> CConnman::vhListenSocket
private

Definition at line 463 of file net.h.

Referenced by BindListenPort(), Stop(), and ThreadSocketHandler().

◆ vNodes

◆ vNodesDisconnected

std::list<CNode*> CConnman::vNodesDisconnected
private

Definition at line 475 of file net.h.

Referenced by Stop(), and ThreadSocketHandler().

◆ vOneShots

std::deque<std::string> CConnman::vOneShots
private

Definition at line 470 of file net.h.

Referenced by AddOneShot(), and ProcessOneShot().

◆ vWhitelistedRange

std::vector<CSubNet> CConnman::vWhitelistedRange
private

Definition at line 457 of file net.h.

Referenced by AddWhitelistedRange(), and IsWhitelistedRange().


The documentation for this class was generated from the following files: