![]() |
Dash Core
0.12.2.1
P2P Digital Currency
|
#include "addrdb.h"
#include "addrman.h"
#include "bloom.h"
#include "compat.h"
#include "limitedmap.h"
#include "netaddress.h"
#include "protocol.h"
#include "random.h"
#include "streams.h"
#include "sync.h"
#include "uint256.h"
#include "util.h"
#include "threadinterrupt.h"
#include <atomic>
#include <deque>
#include <stdint.h>
#include <thread>
#include <memory>
#include <condition_variable>
#include <arpa/inet.h>
#include <boost/filesystem/path.hpp>
#include <boost/foreach.hpp>
#include <boost/signals2/signal.hpp>
Go to the source code of this file.
Classes | |
struct | AddedNodeInfo |
class | CConnman |
struct | CConnman::Options |
struct | CConnman::CFullyConnectedOnly |
struct | CConnman::CAllNodes |
struct | CConnman::ListenSocket |
struct | CombinerAll |
struct | CNodeSignals |
struct | LocalServiceInfo |
class | CNodeStats |
class | CNetMessage |
class | CNode |
class | CExplicitNetCleanup |
Typedefs | |
typedef int | 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) |
CNodeSignals & | GetNodeSignals () |
bool | IsPeerAddrLocalGood (CNode *pnode) |
void | AdvertiseLocal (CNode *pnode) |
void | SetLimited (enum Network net, bool fLimited=true) |
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) |
bool | IsLocal (const CService &addr) |
bool | GetLocal (CService &addr, const CNetAddr *paddrPeer=NULL) |
bool | IsReachable (enum Network net) |
bool | IsReachable (const CNetAddr &addr) |
CAddress | GetLocalAddress (const CNetAddr *paddrPeer, ServiceFlags nLocalServices) |
int64_t | PoissonNextSend (int64_t nNow, int average_interval_seconds) |
Variables | |
static const int | PING_INTERVAL = 2 * 60 |
static const int | TIMEOUT_INTERVAL = 20 * 60 |
static const int | WARNING_INTERVAL = 10 * 60 |
static const int | FEELER_INTERVAL = 120 |
static const unsigned int | MAX_INV_SZ = 50000 |
static const unsigned int | MAX_ADDR_TO_SEND = 1000 |
static const unsigned int | MAX_PROTOCOL_MESSAGE_LENGTH = 3 * 1024 * 1024 |
static const unsigned int | MAX_SUBVERSION_LENGTH = 256 |
static const int | MAX_OUTBOUND_CONNECTIONS = 8 |
static const int | MAX_OUTBOUND_MASTERNODE_CONNECTIONS = 20 |
static const bool | DEFAULT_LISTEN = true |
static const bool | DEFAULT_UPNP = false |
static const size_t | MAPASKFOR_MAX_SZ = MAX_INV_SZ |
static const size_t | SETASKFOR_MAX_SZ = 2 * MAX_INV_SZ |
static const unsigned int | DEFAULT_MAX_PEER_CONNECTIONS = 125 |
static const uint64_t | DEFAULT_MAX_UPLOAD_TARGET = 0 |
static const bool | DEFAULT_BLOCKSONLY = false |
static const bool | DEFAULT_FORCEDNSSEED = false |
static const size_t | DEFAULT_MAXRECEIVEBUFFER = 5 * 1000 |
static const size_t | DEFAULT_MAXSENDBUFFER = 1 * 1000 |
static const ServiceFlags | REQUIRED_SERVICES = NODE_NETWORK |
static const unsigned int | DEFAULT_MISBEHAVING_BANTIME = 60 * 60 * 24 |
std::unique_ptr< CConnman > | g_connman |
bool | fDiscover |
bool | fListen |
bool | fRelayTxes |
std::map< CInv, CDataStream > | mapRelay |
std::deque< std::pair< int64_t, CInv > > | vRelayExpiration |
CCriticalSection | cs_mapRelay |
limitedmap< uint256, int64_t > | mapAlreadyAskedFor |
std::string | strSubVersion |
CCriticalSection | cs_mapLocalHost |
std::map< CNetAddr, LocalServiceInfo > | mapLocalHost |
typedef std::map<std::string, uint64_t> mapMsgCmdSize |
anonymous enum |
bool AddLocal | ( | const CService & | addr, |
int | nScore = LOCAL_NONE |
||
) |
Definition at line 205 of file net.cpp.
Referenced by TorController::add_onion_cb(), AddLocal(), AppInit2(), CConnman::BindListenPort(), and Discover().
bool AddLocal | ( | const CNetAddr & | addr, |
int | nScore = LOCAL_NONE |
||
) |
void AdvertiseLocal | ( | CNode * | pnode | ) |
Definition at line 183 of file net.cpp.
Referenced by SendMessages().
bool BindListenPort | ( | const CService & | bindAddr, |
std::string & | strError, | ||
bool | fWhitelisted = false |
||
) |
void Discover | ( | boost::thread_group & | threadGroup | ) |
Definition at line 2062 of file net.cpp.
Referenced by AppInit2().
unsigned short GetListenPort | ( | ) |
Definition at line 100 of file net.cpp.
Referenced by TorController::add_onion_cb(), AddLocal(), AppInit2(), TorController::auth_cb(), and GetLocalAddress().
Definition at line 106 of file net.cpp.
Referenced by GetLocalAddress(), and CActiveMasternode::ManageStateInitial().
CAddress GetLocalAddress | ( | const CNetAddr * | paddrPeer, |
ServiceFlags | nLocalServices | ||
) |
Definition at line 155 of file net.cpp.
Referenced by AdvertiseLocal(), and ProcessMessage().
CNodeSignals& GetNodeSignals | ( | ) |
Definition at line 92 of file net.cpp.
Referenced by CConnman::AcceptConnection(), AppInit2(), CConnman::ConnectNode(), CConnman::DeleteNode(), PrepareShutdown(), CConnman::Start(), and CConnman::ThreadMessageHandler().
bool IsLimited | ( | enum Network | net | ) |
Definition at line 253 of file net.cpp.
Referenced by AddLocal(), Bind(), GetNetworksInfo(), IsLimited(), IsPeerAddrLocalGood(), and CConnman::ThreadOpenConnections().
bool IsLocal | ( | const CService & | addr | ) |
check whether a given address is potentially local
Definition at line 278 of file net.cpp.
Referenced by CConnman::ConnectNode(), CConnman::OpenNetworkConnection(), and CConnman::ThreadOpenConnections().
bool IsPeerAddrLocalGood | ( | CNode * | pnode | ) |
Definition at line 176 of file net.cpp.
Referenced by AdvertiseLocal(), and ProcessMessage().
bool IsReachable | ( | enum Network | net | ) |
check whether a given network is one we can probably connect to
Definition at line 285 of file net.cpp.
Referenced by GetNetworksInfo(), IsReachable(), CMasternode::IsValidNetAddr(), and ProcessMessage().
bool IsReachable | ( | const CNetAddr & | addr | ) |
void MapPort | ( | bool | fUseUPnP | ) |
Definition at line 1511 of file net.cpp.
Referenced by AppInit2(), PrepareShutdown(), and OptionsModel::setData().
int64_t PoissonNextSend | ( | int64_t | nNow, |
int | average_interval_seconds | ||
) |
Return a timestamp in the future (in microseconds) for exponentially distributed events.
Definition at line 2892 of file net.cpp.
Referenced by SendMessages(), and CConnman::ThreadOpenConnections().
bool RemoveLocal | ( | const CService & | addr | ) |
Definition at line 236 of file net.cpp.
Referenced by TorController::disconnected_cb(), and TorController::~TorController().
bool SeenLocal | ( | const CService & | addr | ) |
void SetLimited | ( | enum Network | net, |
bool | fLimited | ||
) |
Make a particular network entirely off-limits (no automatic connects to it)
Definition at line 245 of file net.cpp.
Referenced by AppInit2(), and TorController::auth_cb().
CCriticalSection cs_mapLocalHost |
Definition at line 79 of file net.cpp.
Referenced by AddLocal(), GetLocal(), getnetworkinfo(), GetnScore(), IsLimited(), IsLocal(), IsReachable(), RemoveLocal(), SeenLocal(), and SetLimited().
CCriticalSection cs_mapRelay |
Definition at line 87 of file net.cpp.
Referenced by ProcessGetData(), and CConnman::RelayTransaction().
|
static |
Default for blocks only
Definition at line 83 of file net.h.
Referenced by AppInit2(), HelpMessage(), and InitParameterInteraction().
|
static |
Definition at line 85 of file net.h.
Referenced by HelpMessage(), and CConnman::ThreadDNSAddressSeed().
|
static |
-listen default
Definition at line 67 of file net.h.
Referenced by AppInit2(), OptionsModel::Init(), and InitParameterInteraction().
|
static |
The maximum number of peer connections to maintain.
Definition at line 79 of file net.h.
Referenced by AppInit2(), and HelpMessage().
|
static |
The default for -maxuploadtarget. 0 = Unlimited
Definition at line 81 of file net.h.
Referenced by AppInit2(), and HelpMessage().
|
static |
Definition at line 86 of file net.h.
Referenced by AppInit2(), and HelpMessage().
|
static |
Definition at line 87 of file net.h.
Referenced by AppInit2(), and HelpMessage().
|
static |
Definition at line 92 of file net.h.
Referenced by CConnman::Ban(), and HelpMessage().
|
static |
-upnp default
Definition at line 72 of file net.h.
Referenced by AppInit2(), and OptionsModel::Init().
bool fDiscover |
Definition at line 76 of file net.cpp.
Referenced by AddLocal(), AppInit2(), CConnman::BindListenPort(), Discover(), and IsPeerAddrLocalGood().
|
static |
Run the feeler connection loop once every 2 minutes or 120 seconds.
Definition at line 53 of file net.h.
Referenced by CConnman::ThreadOpenConnections().
bool fListen |
Definition at line 77 of file net.cpp.
Referenced by AdvertiseLocal(), AppInit2(), GetLocal(), CActiveMasternode::ManageStateInitial(), and ProcessMessage().
bool fRelayTxes |
Definition at line 78 of file net.cpp.
Referenced by AppInit2(), getnetworkinfo(), and ProcessMessage().
std::unique_ptr<CConnman> g_connman |
Definition at line 103 of file init.cpp.
Referenced by addnode(), AppInit2(), RPCConsole::banSelectedNode(), clearbanned(), disconnectnode(), RPCConsole::disconnectSelectedNode(), getaddednodeinfo(), getblocktemplate(), getconnectioncount(), getinfo(), getnettotals(), ClientModel::getNetworkActive(), getnetworkinfo(), ClientModel::getNumConnections(), getpeerinfo(), ClientModel::getTotalBytesRecv(), ClientModel::getTotalBytesSent(), gobject(), Interrupt(), listbanned(), masternode(), masternodebroadcast(), mnsync(), ping(), PrepareShutdown(), privatesend(), OverviewPage::privateSendAuto(), BanTablePriv::refreshBanlist(), PeerTablePriv::refreshPeers(), CMasternodeVerification::Relay(), CDarkSendRelay::RelayThroughNode(), resendwallettransactions(), WalletModel::sendCoins(), sendmany(), SendMoney(), sendrawtransaction(), setban(), setgenerate(), ClientModel::setNetworkActive(), setnetworkactive(), spork(), MasternodeList::StartAlias(), MasternodeList::StartAll(), RPCConsole::unbanSelectedNode(), and voteraw().
limitedmap<uint256, int64_t> mapAlreadyAskedFor |
Referenced by CNode::AskFor(), and ProcessMessage().
|
static |
The maximum number of entries in mapAskFor
Definition at line 75 of file net.h.
Referenced by CNode::AskFor().
std::map<CNetAddr, LocalServiceInfo> mapLocalHost |
Definition at line 80 of file net.cpp.
Referenced by AddLocal(), GetLocal(), getnetworkinfo(), GetnScore(), IsLocal(), RemoveLocal(), and SeenLocal().
std::map<CInv, CDataStream> mapRelay |
Definition at line 85 of file net.cpp.
Referenced by ProcessGetData(), and CConnman::RelayTransaction().
|
static |
The maximum number of new addresses to accumulate before announcing.
Definition at line 57 of file net.h.
Referenced by CNode::PushAddress().
|
static |
The maximum number of entries in an 'inv' protocol message
Definition at line 55 of file net.h.
Referenced by ProcessMessage(), and CMasternodePayments::RequestLowDataPaymentBlocks().
|
static |
|
static |
Maximum number if outgoing masternodes
Definition at line 65 of file net.h.
Referenced by CConnman::Start(), and CConnman::Stop().
|
static |
Maximum length of incoming protocol messages (no message over 3 MiB is currently acceptable).
Definition at line 59 of file net.h.
Referenced by CNode::ReceiveMsgBytes().
|
static |
Maximum length of strSubVer in version
message
Definition at line 61 of file net.h.
Referenced by AppInit2(), and ProcessMessage().
|
static |
Time between pings automatically sent out for latency probing and keepalive (in seconds).
Definition at line 47 of file net.h.
Referenced by SendMessages().
|
static |
Definition at line 89 of file net.h.
Referenced by ProcessMessage(), and CConnman::ThreadOpenConnections().
|
static |
The maximum number of entries in setAskFor (larger due to getdata latency)
Definition at line 77 of file net.h.
Referenced by CNode::AskFor(), and CGovernanceManager::RequestGovernanceObjectVotes().
std::string strSubVersion |
Subversion as sent to the P2P network in version
messages
Definition at line 83 of file net.cpp.
Referenced by AppInit2(), ClientModel::formatSubVersion(), and getnetworkinfo().
|
static |
Time after which to disconnect, after waiting for a ping response (or inactivity).
Definition at line 49 of file net.h.
Referenced by CConnman::ThreadSocketHandler().
std::deque<std::pair<int64_t, CInv> > vRelayExpiration |
Definition at line 86 of file net.cpp.
Referenced by CConnman::RelayTransaction().
|
static |
Minimum time between warnings printed to log.
Definition at line 51 of file net.h.
Referenced by CNode::AskFor().