Dash Core Source Documentation (0.16.0.1)
Find detailed information regarding the Dash Core source code.
#include <addrdb.h>
#include <addrman.h>
#include <bloom.h>
#include <compat.h>
#include <fs.h>
#include <hash.h>
#include <limitedmap.h>
#include <netaddress.h>
#include <policy/feerate.h>
#include <protocol.h>
#include <random.h>
#include <saltedhasher.h>
#include <streams.h>
#include <sync.h>
#include <uint256.h>
#include <util.h>
#include <threadinterrupt.h>
#include <consensus/params.h>
#include <atomic>
#include <deque>
#include <stdint.h>
#include <thread>
#include <memory>
#include <condition_variable>
#include <unordered_set>
#include <queue>
#include <arpa/inet.h>
Go to the source code of this file.
Classes | |
struct | AddedNodeInfo |
struct | CSerializedNetMsg |
class | CConnman |
struct | CConnman::Options |
struct | CConnman::CFullyConnectedOnly |
struct | CConnman::CAllNodes |
struct | CConnman::ListenSocket |
struct | CombinerAll |
class | NetEventsInterface |
Interface for message handling. More... | |
struct | LocalServiceInfo |
class | CNodeStats |
class | CNetMessage |
class | CNode |
Information about a peer. More... | |
class | CExplicitNetCleanup |
Macros | |
#define | USE_WAKEUP_PIPE |
#define | DEFAULT_SOCKETEVENTS "select" |
Typedefs | |
typedef int64_t | NodeId |
typedef std::map< std::string, uint64_t > | mapMsgCmdSize |
Enumerations | |
enum | { LOCAL_NONE, LOCAL_IF, LOCAL_BIND, LOCAL_UPNP, LOCAL_MANUAL, LOCAL_MAX } |
Functions | |
void | Discover (boost::thread_group &threadGroup) |
void | MapPort (bool fUseUPnP) |
unsigned short | GetListenPort () |
bool | BindListenPort (const CService &bindAddr, std::string &strError, bool fWhitelisted=false) |
bool | IsPeerAddrLocalGood (CNode *pnode) |
void | AdvertiseLocal (CNode *pnode) |
void | SetLimited (enum Network net, bool fLimited=true) |
Make a particular network entirely off-limits (no automatic connects to it) More... | |
bool | IsLimited (enum Network net) |
bool | IsLimited (const CNetAddr &addr) |
bool | AddLocal (const CService &addr, int nScore=LOCAL_NONE) |
bool | AddLocal (const CNetAddr &addr, int nScore=LOCAL_NONE) |
bool | RemoveLocal (const CService &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 | GetLocal (CService &addr, const CNetAddr *paddrPeer=nullptr) |
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... | |
CAddress | GetLocalAddress (const CNetAddr *paddrPeer, ServiceFlags nLocalServices) |
std::map< CNetAddr, LocalServiceInfo > mapLocalHost | GUARDED_BY (cs_mapLocalHost) |
int64_t | PoissonNextSend (int64_t now, int average_interval_seconds) |
Return a timestamp in the future (in microseconds) for exponentially distributed events. More... | |
std::chrono::microseconds | PoissonNextSend (std::chrono::microseconds now, std::chrono::seconds average_interval) |
Wrapper to return mockable type. More... | |
Variables | |
static const int | PING_INTERVAL = 2 * 60 |
Time between pings automatically sent out for latency probing and keepalive (in seconds). More... | |
static const int | TIMEOUT_INTERVAL = 20 * 60 |
Time after which to disconnect, after waiting for a ping response (or inactivity). More... | |
static const int | WARNING_INTERVAL = 10 * 60 |
Minimum time between warnings printed to log. More... | |
static const int | FEELER_INTERVAL = 120 |
Run the feeler connection loop once every 2 minutes or 120 seconds. More... | |
static const unsigned int | MAX_INV_SZ = 50000 |
The maximum number of entries in an 'inv' protocol message. More... | |
static const unsigned int | MAX_ADDR_TO_SEND = 1000 |
The maximum number of new addresses to accumulate before announcing. More... | |
static const unsigned int | MAX_PROTOCOL_MESSAGE_LENGTH = 3 * 1024 * 1024 |
Maximum length of incoming protocol messages (no message over 3 MiB is currently acceptable). More... | |
static const unsigned int | MAX_SUBVERSION_LENGTH = 256 |
Maximum length of strSubVer in version message. More... | |
static const int | MAX_OUTBOUND_CONNECTIONS = 8 |
Maximum number of automatic outgoing nodes. More... | |
static const int | MAX_ADDNODE_CONNECTIONS = 8 |
Maximum number of addnode outgoing nodes. More... | |
static const int | INBOUND_EVICTION_PROTECTION_TIME = 1 |
Eviction protection time for incoming connections. More... | |
static const bool | DEFAULT_LISTEN = true |
-listen default More... | |
static const bool | DEFAULT_UPNP = false |
-upnp default More... | |
static const unsigned int | DEFAULT_MAX_PEER_CONNECTIONS = 125 |
The maximum number of peer connections to maintain. More... | |
static const uint64_t | DEFAULT_MAX_UPLOAD_TARGET = 0 |
The default for -maxuploadtarget. More... | |
static const uint64_t | MAX_UPLOAD_TIMEFRAME = 60 * 60 * 24 |
The default timeframe for -maxuploadtarget. More... | |
static const bool | DEFAULT_BLOCKSONLY = false |
Default for blocks only. More... | |
static const bool | DEFAULT_FORCEDNSSEED = false |
static const size_t | DEFAULT_MAXRECEIVEBUFFER = 5 * 1000 |
static const size_t | DEFAULT_MAXSENDBUFFER = 1 * 1000 |
static const unsigned int | DEFAULT_MISBEHAVING_BANTIME = 60 * 60 * 24 |
std::unique_ptr< CConnman > | g_connman |
bool | fDiscover |
bool | fListen |
bool | fRelayTxes |
std::string | strSubVersion |
Subversion as sent to the P2P network in version messages. More... | |
CCriticalSection | cs_mapLocalHost |
Macro Definition Documentation
◆ DEFAULT_SOCKETEVENTS
#define DEFAULT_SOCKETEVENTS "select" |
Definition at line 106 of file net.h.
Referenced by AppInitMain(), and HelpMessage().
◆ USE_WAKEUP_PIPE
Typedef Documentation
◆ mapMsgCmdSize
typedef std::map<std::string, uint64_t> mapMsgCmdSize |
◆ NodeId
Enumeration Type Documentation
◆ anonymous enum
anonymous enum |
Function Documentation
◆ AddLocal() [1/2]
bool AddLocal | ( | const CService & | addr, |
int | nScore = LOCAL_NONE |
||
) |
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 = LOCAL_NONE |
||
) |
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().
◆ BindListenPort()
bool BindListenPort | ( | const CService & | bindAddr, |
std::string & | strError, | ||
bool | fWhitelisted = false |
||
) |
◆ 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().
◆ 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().
◆ 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 | fUseUPnP | ) |
Definition at line 2065 of file net.cpp.
Referenced by AppInitMain(), PrepareShutdown(), and OptionsModel::setData().
◆ PoissonNextSend() [1/2]
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().
◆ PoissonNextSend() [2/2]
|
inline |
Wrapper to return mockable type.
Definition at line 1109 of file net.h.
References PoissonNextSend().
◆ 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().
◆ 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()
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().
◆ DEFAULT_BLOCKSONLY
|
static |
Default for blocks only.
Definition at line 92 of file net.h.
Referenced by AppInitMain(), HelpMessage(), InitParameterInteraction(), and WalletInit::ParameterInteraction().
◆ DEFAULT_FORCEDNSSEED
|
static |
Definition at line 94 of file net.h.
Referenced by HelpMessage(), and CConnman::ThreadDNSAddressSeed().
◆ DEFAULT_LISTEN
|
static |
-listen default
Definition at line 76 of file net.h.
Referenced by AppInitMain(), AppInitParameterInteraction(), OptionsModel::Init(), and InitParameterInteraction().
◆ DEFAULT_MAX_PEER_CONNECTIONS
|
static |
The maximum number of peer connections to maintain.
Masternodes are forced to accept at least this many connections
Definition at line 86 of file net.h.
Referenced by AppInitParameterInteraction(), and HelpMessage().
◆ DEFAULT_MAX_UPLOAD_TARGET
|
static |
The default for -maxuploadtarget.
0 = Unlimited
Definition at line 88 of file net.h.
Referenced by AppInitMain(), and HelpMessage().
◆ DEFAULT_MAXRECEIVEBUFFER
|
static |
Definition at line 95 of file net.h.
Referenced by AppInitMain(), and HelpMessage().
◆ DEFAULT_MAXSENDBUFFER
|
static |
Definition at line 96 of file net.h.
Referenced by AppInitMain(), and HelpMessage().
◆ DEFAULT_MISBEHAVING_BANTIME
|
static |
Definition at line 99 of file net.h.
Referenced by CConnman::Ban(), and HelpMessage().
◆ DEFAULT_UPNP
|
static |
-upnp default
Definition at line 81 of file net.h.
Referenced by AppInitMain(), and OptionsModel::Init().
◆ fDiscover
bool fDiscover |
Definition at line 112 of file net.cpp.
Referenced by AddLocal(), AppInitMain(), CConnman::BindListenPort(), Discover(), and IsPeerAddrLocalGood().
◆ FEELER_INTERVAL
|
static |
Run the feeler connection loop once every 2 minutes or 120 seconds.
Definition at line 60 of file net.h.
Referenced by CConnman::ThreadOpenConnections().
◆ fListen
bool fListen |
Definition at line 113 of file net.cpp.
Referenced by AdvertiseLocal(), AppInitMain(), GetLocal(), CActiveMasternodeManager::Init(), ProcessMessage(), and CConnman::Start().
◆ fRelayTxes
bool fRelayTxes |
Definition at line 114 of file net.cpp.
Referenced by AppInitMain(), getnetworkinfo(), and ProcessMessage().
◆ g_connman
std::unique_ptr<CConnman> g_connman |
Definition at line 97 of file init.cpp.
Referenced by llmq::CQuorumBlockProcessor::AddMinableCommitment(), addnode(), llmq::CLLMQUtils::AddQuorumProbeConnections(), AppInitMain(), llmq::CInstantSendManager::AskNodesForLockedTx(), RPCConsole::banSelectedNode(), PeerLogicValidation::BlockConnected(), llmq::CSigSharesManager::Cleanup(), clearbanned(), llmq::CSigSharesManager::CollectSigSharesToAnnounce(), CTransactionBuilder::Commit(), disconnectnode(), RPCConsole::disconnectSelectedNode(), llmq::CLLMQUtils::EnsureQuorumConnections(), llmq::CQuorumManager::EnsureQuorumConnections(), getaddednodeinfo(), getblocktemplate(), getconnectioncount(), CActiveMasternodeManager::GetLocalAddress(), getnettotals(), ClientModel::getNetworkActive(), getnetworkinfo(), ClientModel::getNumConnections(), getpeerinfo(), ClientModel::getTotalBytesRecv(), ClientModel::getTotalBytesSent(), gobject_submit(), gobject_vote_conf(), Interrupt(), listbanned(), masternode_connect(), mnsync(), CMNAuth::NotifyMasternodeListChanged(), ping(), PrepareShutdown(), llmq::CInstantSendManager::ProcessInstantSendLock(), llmq::CChainLocksHandler::ProcessNewChainLock(), llmq::CSigningManager::ProcessPendingReconstructedRecoveredSigs(), llmq::CInstantSendManager::ProcessTx(), quorum_dkgstatus(), BanTablePriv::refreshBanlist(), PeerTablePriv::refreshPeers(), llmq::CDKGSession::RelayInvToParticipants(), resendwallettransactions(), WalletModel::sendCoins(), sendmany(), llmq::CSigSharesManager::SendMessages(), SendMoney(), sendrawtransaction(), setban(), ClientModel::setNetworkActive(), setnetworkactive(), llmq::CSigSharesManager::Sign(), spork(), WalletInit::Start(), RPCConsole::unbanSelectedNode(), llmq::CDKGSession::VerifyConnectionAndMinProtoVersions(), voteraw(), VoteWithMasternodes(), and llmq::CSigSharesManager::WorkThreadMain().
◆ INBOUND_EVICTION_PROTECTION_TIME
|
static |
Eviction protection time for incoming connections.
Definition at line 74 of file net.h.
Referenced by CConnman::AttemptToEvictConnection().
◆ MAX_ADDNODE_CONNECTIONS
|
static |
Maximum number of addnode outgoing nodes.
Definition at line 72 of file net.h.
Referenced by AppInitMain(), and AppInitParameterInteraction().
◆ MAX_ADDR_TO_SEND
|
static |
The maximum number of new addresses to accumulate before announcing.
Definition at line 64 of file net.h.
Referenced by CNode::PushAddress().
◆ MAX_INV_SZ
|
static |
The maximum number of entries in an 'inv' protocol message.
Definition at line 62 of file net.h.
Referenced by ProcessMessage(), CGovernanceManager::RequestGovernanceObjectVotes(), and PeerLogicValidation::SendMessages().
◆ MAX_OUTBOUND_CONNECTIONS
|
static |
Maximum number of automatic outgoing nodes.
Definition at line 70 of file net.h.
Referenced by AppInitMain().
◆ MAX_PROTOCOL_MESSAGE_LENGTH
|
static |
Maximum length of incoming protocol messages (no message over 3 MiB is currently acceptable).
Definition at line 66 of file net.h.
Referenced by CNode::ReceiveMsgBytes().
◆ MAX_SUBVERSION_LENGTH
|
static |
Maximum length of strSubVer in version
message.
Definition at line 68 of file net.h.
Referenced by AppInitMain(), and ProcessMessage().
◆ MAX_UPLOAD_TIMEFRAME
|
static |
The default timeframe for -maxuploadtarget.
1 day.
Definition at line 90 of file net.h.
Referenced by AppInitMain().
◆ PING_INTERVAL
|
static |
Time between pings automatically sent out for latency probing and keepalive (in seconds).
Definition at line 54 of file net.h.
Referenced by PeerLogicValidation::SendMessages().
◆ 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().
◆ TIMEOUT_INTERVAL
|
static |
Time after which to disconnect, after waiting for a ping response (or inactivity).
Definition at line 56 of file net.h.
Referenced by CConnman::InactivityCheck().