Dash Core Source Documentation (0.16.0.1)
Find detailed information regarding the Dash Core source code.
#include <net.h>#include <netmessagemaker.h>#include <chainparams.h>#include <clientversion.h>#include <consensus/consensus.h>#include <crypto/common.h>#include <crypto/sha256.h>#include <primitives/transaction.h>#include <netbase.h>#include <scheduler.h>#include <ui_interface.h>#include <utilstrencodings.h>#include <validation.h>#include <masternode/masternode-meta.h>#include <masternode/masternode-sync.h>#include <privatesend/privatesend.h>#include <evo/deterministicmns.h>#include <memory>#include <fcntl.h>#include <unordered_map>#include <math.h>
Include dependency graph for net.cpp:Go to the source code of this file.
Classes | |
| struct | NodeEvictionCandidate |
| class | CNetCleanup |
Macros | |
| #define | DUMP_ADDRESSES_INTERVAL 900 |
| #define | FEELER_SLEEP_WINDOW 1 |
| #define | MSG_NOSIGNAL 0 |
| #define | MSG_DONTWAIT 0 |
| #define | X(name) stats.name = name |
Enumerations | |
| enum | BindFlags { BF_NONE = 0, BF_EXPLICIT = (1U << 0), BF_REPORT_ERROR = (1U << 1), BF_WHITELIST = (1U << 2) } |
| Used to pass flags to the Bind() function. More... | |
Functions | |
| std::map< CNetAddr, LocalServiceInfo > mapLocalHost | GUARDED_BY (cs_mapLocalHost) |
| unsigned short | GetListenPort () |
| bool | GetLocal (CService &addr, const CNetAddr *paddrPeer) |
| static std::vector< CAddress > | convertSeed6 (const std::vector< SeedSpec6 > &vSeedsIn) |
| Convert the pnSeed6 array into usable address objects. More... | |
| CAddress | GetLocalAddress (const CNetAddr *paddrPeer, ServiceFlags nLocalServices) |
| int | GetnScore (const CService &addr) |
| bool | IsPeerAddrLocalGood (CNode *pnode) |
| void | AdvertiseLocal (CNode *pnode) |
| bool | AddLocal (const CService &addr, int nScore) |
| bool | AddLocal (const CNetAddr &addr, int nScore) |
| bool | RemoveLocal (const CService &addr) |
| void | SetLimited (enum Network net, bool fLimited) |
| Make a particular network entirely off-limits (no automatic connects to it) More... | |
| bool | IsLimited (enum Network net) |
| bool | IsLimited (const CNetAddr &addr) |
| bool | SeenLocal (const CService &addr) |
| vote for a local address More... | |
| bool | IsLocal (const CService &addr) |
| check whether a given address is potentially local More... | |
| bool | IsReachable (enum Network net) |
| check whether a given network is one we can probably connect to More... | |
| bool | IsReachable (const CNetAddr &addr) |
| check whether a given address is in a network we can probably connect to More... | |
| static CAddress | GetBindAddress (SOCKET sock) |
| Get the bind address for a socket as CAddress. More... | |
| static bool | ReverseCompareNodeMinPingTime (const NodeEvictionCandidate &a, const NodeEvictionCandidate &b) |
| static bool | ReverseCompareNodeTimeConnected (const NodeEvictionCandidate &a, const NodeEvictionCandidate &b) |
| static bool | CompareNetGroupKeyed (const NodeEvictionCandidate &a, const NodeEvictionCandidate &b) |
| static bool | CompareNodeBlockTime (const NodeEvictionCandidate &a, const NodeEvictionCandidate &b) |
| static bool | CompareNodeTXTime (const NodeEvictionCandidate &a, const NodeEvictionCandidate &b) |
| template<typename T , typename Comparator > | |
| static void | EraseLastKElements (std::vector< T > &elements, Comparator comparator, size_t k) |
| Sort an array by the specified comparator, then erase the last K elements. More... | |
| void | MapPort (bool) |
| void | Discover (boost::thread_group &threadGroup) |
| int64_t | PoissonNextSend (int64_t now, int average_interval_seconds) |
| Return a timestamp in the future (in microseconds) for exponentially distributed events. More... | |
Variables | |
| static const uint64_t | SELECT_TIMEOUT_MILLISECONDS = 50 |
| static const std::string | NET_MESSAGE_COMMAND_OTHER = "*other*" |
| static const uint64_t | RANDOMIZER_ID_NETGROUP = 0x6c0edd8036ef4036ULL |
| static const uint64_t | RANDOMIZER_ID_LOCALHOSTNONCE = 0xd93e69e2bbfa5735ULL |
| bool | fDiscover = true |
| bool | fListen = true |
| bool | fRelayTxes = true |
| CCriticalSection | cs_mapLocalHost |
| std::string | strSubVersion |
Subversion as sent to the P2P network in version messages. More... | |
| class CNetCleanup | instance_of_cnetcleanup |
Macro Definition Documentation
◆ DUMP_ADDRESSES_INTERVAL
| #define DUMP_ADDRESSES_INTERVAL 900 |
Definition at line 58 of file net.cpp.
Referenced by CConnman::Start().
◆ FEELER_SLEEP_WINDOW
| #define FEELER_SLEEP_WINDOW 1 |
Definition at line 61 of file net.cpp.
Referenced by CConnman::ThreadOpenConnections().
◆ MSG_DONTWAIT
| #define MSG_DONTWAIT 0 |
Definition at line 69 of file net.cpp.
Referenced by CConnman::SocketRecvData(), and CConnman::SocketSendData().
◆ MSG_NOSIGNAL
| #define MSG_NOSIGNAL 0 |
Definition at line 64 of file net.cpp.
Referenced by CConnman::SocketSendData().
◆ X
| #define X | ( | name | ) | stats.name = name |
Definition at line 756 of file net.cpp.
Referenced by CNode::copyStats(), and memusage::DynamicUsage().
Enumeration Type Documentation
◆ BindFlags
| enum BindFlags |
Function Documentation
◆ AddLocal() [1/2]
| bool AddLocal | ( | const CService & | addr, |
| int | nScore | ||
| ) |
Definition at line 236 of file net.cpp.
References cs_mapLocalHost, fDiscover, CService::GetPort(), IsLimited(), CNetAddr::IsRoutable(), LOCAL_MANUAL, LOCK, LogPrintf, LocalServiceInfo::nPort, LocalServiceInfo::nScore, Params(), CChainParams::RequireRoutableExternalIP(), and CService::ToString().
Referenced by TorController::add_onion_cb(), AddLocal(), AppInitMain(), CConnman::BindListenPort(), and Discover().
◆ AddLocal() [2/2]
| bool AddLocal | ( | const CNetAddr & | addr, |
| int | nScore | ||
| ) |
Definition at line 262 of file net.cpp.
References AddLocal(), and GetListenPort().
◆ AdvertiseLocal()
| void AdvertiseLocal | ( | CNode * | pnode | ) |
Definition at line 209 of file net.cpp.
References CNode::addr, fListen, CNode::fSuccessfullyConnected, gArgs, CNode::GetAddrLocal(), ArgsManager::GetBoolArg(), GetListenPort(), GetLocalAddress(), CNode::GetLocalServices(), GetnScore(), GetRand(), IsPeerAddrLocalGood(), CNetAddr::IsRoutable(), LOCAL_MANUAL, LogPrint, LookupNumeric(), BCLog::NET, CNode::PushAddress(), CNetAddr::SetIP(), and CService::ToString().
Referenced by PeerLogicValidation::SendMessages().
◆ CompareNetGroupKeyed()
|
static |
Definition at line 1034 of file net.cpp.
References NodeEvictionCandidate::nKeyedNetGroup.
Referenced by CConnman::AttemptToEvictConnection().
◆ CompareNodeBlockTime()
|
static |
Definition at line 1038 of file net.cpp.
References NodeEvictionCandidate::fRelevantServices, NodeEvictionCandidate::nLastBlockTime, and NodeEvictionCandidate::nTimeConnected.
Referenced by CConnman::AttemptToEvictConnection().
◆ CompareNodeTXTime()
|
static |
Definition at line 1046 of file net.cpp.
References NodeEvictionCandidate::fBloomFilter, NodeEvictionCandidate::fRelayTxes, NodeEvictionCandidate::nLastTXTime, and NodeEvictionCandidate::nTimeConnected.
Referenced by CConnman::AttemptToEvictConnection().
◆ convertSeed6()
Convert the pnSeed6 array into usable address objects.
Definition at line 157 of file net.cpp.
References GetDesirableServiceFlags(), GetRand(), GetTime(), memcpy(), NODE_NONE, and CAddress::nTime.
Referenced by CConnman::ThreadOpenConnections().
◆ Discover()
| void Discover | ( | boost::thread_group & | threadGroup | ) |
Definition at line 2835 of file net.cpp.
References AddLocal(), fDiscover, LOCAL_IF, LogPrintf, LookupHost(), SOCKET_ERROR, and CNetAddr::ToString().
Referenced by AppInitMain().
◆ EraseLastKElements()
|
static |
Sort an array by the specified comparator, then erase the last K elements.
Definition at line 1058 of file net.cpp.
Referenced by CConnman::AttemptToEvictConnection().
◆ GetBindAddress()
Get the bind address for a socket as CAddress.
Definition at line 397 of file net.cpp.
References INVALID_SOCKET, LogPrint, BCLog::NET, and CService::SetSockAddr().
Referenced by CConnman::AcceptConnection(), and CConnman::ConnectNode().
◆ GetListenPort()
| unsigned short GetListenPort | ( | ) |
Definition at line 126 of file net.cpp.
References gArgs, ArgsManager::GetArg(), and Params().
Referenced by TorController::add_onion_cb(), AddLocal(), AdvertiseLocal(), AppInitMain(), TorController::auth_cb(), CConnman::ConnectNode(), CActiveMasternodeManager::GetLocalAddress(), GetLocalAddress(), CConnman::InitBinds(), CConnman::OpenNetworkConnection(), and CConnman::ThreadOpenConnections().
◆ GetLocal()
Definition at line 132 of file net.cpp.
References cs_mapLocalHost, fListen, and LOCK.
Referenced by CActiveMasternodeManager::GetLocalAddress(), and GetLocalAddress().
◆ GetLocalAddress()
| CAddress GetLocalAddress | ( | const CNetAddr * | paddrPeer, |
| ServiceFlags | nLocalServices | ||
| ) |
Definition at line 180 of file net.cpp.
References GetAdjustedTime(), GetListenPort(), GetLocal(), and CAddress::nTime.
Referenced by AdvertiseLocal(), and ProcessMessage().
◆ GetnScore()
| int GetnScore | ( | const CService & | addr | ) |
Definition at line 192 of file net.cpp.
References cs_mapLocalHost, LOCAL_NONE, and LOCK.
Referenced by AdvertiseLocal().
◆ GUARDED_BY()
| std::map<CNetAddr, LocalServiceInfo> mapLocalHost GUARDED_BY | ( | cs_mapLocalHost | ) |
◆ IsLimited() [1/2]
| bool IsLimited | ( | enum Network | net | ) |
Definition at line 284 of file net.cpp.
References cs_mapLocalHost, and LOCK.
Referenced by AddLocal(), CConnman::Bind(), GetNetworksInfo(), IsLimited(), IsPeerAddrLocalGood(), and CConnman::ThreadOpenConnections().
◆ IsLimited() [2/2]
| bool IsLimited | ( | const CNetAddr & | addr | ) |
Definition at line 290 of file net.cpp.
References CNetAddr::GetNetwork(), and IsLimited().
◆ IsLocal()
| bool IsLocal | ( | const CService & | addr | ) |
check whether a given address is potentially local
Definition at line 309 of file net.cpp.
References cs_mapLocalHost, and LOCK.
Referenced by CConnman::ConnectNode(), CConnman::OpenNetworkConnection(), and CConnman::ThreadOpenConnections().
◆ IsPeerAddrLocalGood()
| bool IsPeerAddrLocalGood | ( | CNode * | pnode | ) |
Definition at line 201 of file net.cpp.
References CNode::addr, fDiscover, CNode::GetAddrLocal(), CNetAddr::GetNetwork(), IsLimited(), and CNetAddr::IsRoutable().
Referenced by AdvertiseLocal(), and ProcessMessage().
◆ IsReachable() [1/2]
| bool IsReachable | ( | enum Network | net | ) |
check whether a given network is one we can probably connect to
Definition at line 316 of file net.cpp.
References cs_mapLocalHost, and LOCK.
Referenced by GetNetworksInfo(), IsReachable(), CActiveMasternodeManager::IsValidNetAddr(), and ProcessMessage().
◆ IsReachable() [2/2]
| bool IsReachable | ( | const CNetAddr & | addr | ) |
check whether a given address is in a network we can probably connect to
Definition at line 323 of file net.cpp.
References CNetAddr::GetNetwork(), and IsReachable().
◆ MapPort()
| void MapPort | ( | bool | ) |
Definition at line 2065 of file net.cpp.
Referenced by AppInitMain(), PrepareShutdown(), and OptionsModel::setData().
◆ PoissonNextSend()
| int64_t PoissonNextSend | ( | int64_t | now, |
| int | average_interval_seconds | ||
| ) |
Return a timestamp in the future (in microseconds) for exponentially distributed events.
Definition at line 3825 of file net.cpp.
References GetRand().
Referenced by PoissonNextSend(), CConnman::PoissonNextSendInbound(), PeerLogicValidation::SendMessages(), and CConnman::ThreadOpenConnections().
◆ RemoveLocal()
| bool RemoveLocal | ( | const CService & | addr | ) |
Definition at line 267 of file net.cpp.
References cs_mapLocalHost, LOCK, LogPrintf, and CService::ToString().
Referenced by TorController::disconnected_cb(), and TorController::~TorController().
◆ ReverseCompareNodeMinPingTime()
|
static |
Definition at line 1024 of file net.cpp.
References NodeEvictionCandidate::nMinPingUsecTime.
Referenced by CConnman::AttemptToEvictConnection().
◆ ReverseCompareNodeTimeConnected()
|
static |
Definition at line 1029 of file net.cpp.
References NodeEvictionCandidate::nTimeConnected.
Referenced by CConnman::AttemptToEvictConnection().
◆ SeenLocal()
| bool SeenLocal | ( | const CService & | addr | ) |
vote for a local address
Definition at line 296 of file net.cpp.
References cs_mapLocalHost, and LOCK.
Referenced by ProcessMessage().
◆ SetLimited()
| void SetLimited | ( | enum Network | net, |
| bool | fLimited | ||
| ) |
Make a particular network entirely off-limits (no automatic connects to it)
Definition at line 276 of file net.cpp.
References cs_mapLocalHost, LOCK, NET_INTERNAL, and NET_UNROUTABLE.
Referenced by AppInitMain(), and TorController::auth_cb().
Variable Documentation
◆ cs_mapLocalHost
| CCriticalSection cs_mapLocalHost |
Definition at line 115 of file net.cpp.
Referenced by AddLocal(), GetLocal(), getnetworkinfo(), GetnScore(), IsLimited(), IsLocal(), IsReachable(), RemoveLocal(), SeenLocal(), and SetLimited().
◆ fDiscover
| bool fDiscover = true |
Definition at line 112 of file net.cpp.
Referenced by AddLocal(), AppInitMain(), CConnman::BindListenPort(), Discover(), and IsPeerAddrLocalGood().
◆ fListen
| bool fListen = true |
Definition at line 113 of file net.cpp.
Referenced by AdvertiseLocal(), AppInitMain(), GetLocal(), CActiveMasternodeManager::Init(), ProcessMessage(), and CConnman::Start().
◆ fRelayTxes
| bool fRelayTxes = true |
Definition at line 114 of file net.cpp.
Referenced by AppInitMain(), getnetworkinfo(), and ProcessMessage().
◆ instance_of_cnetcleanup
| class CNetCleanup instance_of_cnetcleanup |
◆ NET_MESSAGE_COMMAND_OTHER
|
static |
Definition at line 102 of file net.cpp.
Referenced by CNode::CNode(), and CNode::ReceiveMsgBytes().
◆ RANDOMIZER_ID_LOCALHOSTNONCE
|
static |
Definition at line 108 of file net.cpp.
Referenced by CConnman::AcceptConnection(), and CConnman::ConnectNode().
◆ RANDOMIZER_ID_NETGROUP
|
static |
Definition at line 107 of file net.cpp.
Referenced by CConnman::CalculateKeyedNetGroup().
◆ SELECT_TIMEOUT_MILLISECONDS
|
static |
Definition at line 94 of file net.cpp.
Referenced by CConnman::SocketEventsSelect().
◆ strSubVersion
| std::string strSubVersion |
Subversion as sent to the P2P network in version messages.
Definition at line 118 of file net.cpp.
Referenced by AppInitMain(), ClientModel::formatSubVersion(), and getnetworkinfo().

