Dash Core  0.12.2.1
P2P Digital Currency
net.cpp File Reference
#include "net.h"
#include "addrman.h"
#include "chainparams.h"
#include "clientversion.h"
#include "consensus/consensus.h"
#include "crypto/common.h"
#include "hash.h"
#include "primitives/transaction.h"
#include "netbase.h"
#include "scheduler.h"
#include "ui_interface.h"
#include "wallet/wallet.h"
#include "utilstrencodings.h"
#include "instantx.h"
#include "masternode-sync.h"
#include "masternodeman.h"
#include "privatesend.h"
#include <fcntl.h>
#include <math.h>

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 X(name)   stats.name = name
 

Functions

CNodeSignalsGetNodeSignals ()
 
unsigned short GetListenPort ()
 
bool GetLocal (CService &addr, const CNetAddr *paddrPeer)
 
static std::vector< CAddressconvertSeed6 (const std::vector< SeedSpec6 > &vSeedsIn)
 Convert the pnSeeds6 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)
 
bool IsLimited (enum Network net)
 
bool IsLimited (const CNetAddr &addr)
 
bool SeenLocal (const CService &addr)
 
bool IsLocal (const CService &addr)
 
bool IsReachable (enum Network net)
 
bool IsReachable (const CNetAddr &addr)
 
static bool ReverseCompareNodeMinPingTime (const NodeEvictionCandidate &a, const NodeEvictionCandidate &b)
 
static bool ReverseCompareNodeTimeConnected (const NodeEvictionCandidate &a, const NodeEvictionCandidate &b)
 
static bool CompareKeyedNetGroup (const NodeEvictionCandidate &a, const NodeEvictionCandidate &b)
 
static bool CompareNodeBlockTime (const NodeEvictionCandidate &a, const NodeEvictionCandidate &b)
 
static bool CompareNodeTXTime (const NodeEvictionCandidate &a, const NodeEvictionCandidate &b)
 
void MapPort (bool)
 
void Discover (boost::thread_group &threadGroup)
 
int64_t PoissonNextSend (int64_t nNow, int average_interval_seconds)
 

Variables

static const std::string NET_MESSAGE_COMMAND_OTHER = "*other*"
 
bool fDiscover = true
 
bool fListen = true
 
bool fRelayTxes = true
 
CCriticalSection cs_mapLocalHost
 
std::map< CNetAddr, LocalServiceInfomapLocalHost
 
static bool vfLimited [NET_MAX] = {}
 
static CNodepnodeLocalHost = NULL
 
std::string strSubVersion
 
std::map< CInv, CDataStreammapRelay
 
std::deque< pair< int64_t, CInv > > vRelayExpiration
 
CCriticalSection cs_mapRelay
 
limitedmap< uint256, int64_t > mapAlreadyAskedFor (MAX_INV_SZ)
 
static CNodeSignals g_signals
 
class CNetCleanup instance_of_cnetcleanup
 

Macro Definition Documentation

◆ DUMP_ADDRESSES_INTERVAL

#define DUMP_ADDRESSES_INTERVAL   900

Definition at line 48 of file net.cpp.

Referenced by CConnman::Start().

◆ FEELER_SLEEP_WINDOW

#define FEELER_SLEEP_WINDOW   1

Definition at line 51 of file net.cpp.

Referenced by CConnman::ThreadOpenConnections().

◆ X

#define X (   name)    stats.name = name

Definition at line 634 of file net.cpp.

Referenced by CNode::copyStats(), and memusage::DynamicUsage().

Function Documentation

◆ AddLocal() [1/2]

bool AddLocal ( const CService addr,
int  nScore 
)

◆ AddLocal() [2/2]

bool AddLocal ( const CNetAddr addr,
int  nScore 
)

Definition at line 231 of file net.cpp.

◆ AdvertiseLocal()

void AdvertiseLocal ( CNode pnode)

Definition at line 183 of file net.cpp.

Referenced by SendMessages().

◆ CompareKeyedNetGroup()

static bool CompareKeyedNetGroup ( const NodeEvictionCandidate a,
const NodeEvictionCandidate b 
)
static

Definition at line 894 of file net.cpp.

Referenced by CConnman::AttemptToEvictConnection().

◆ CompareNodeBlockTime()

static bool CompareNodeBlockTime ( const NodeEvictionCandidate a,
const NodeEvictionCandidate b 
)
static

Definition at line 899 of file net.cpp.

Referenced by CConnman::AttemptToEvictConnection().

◆ CompareNodeTXTime()

static bool CompareNodeTXTime ( const NodeEvictionCandidate a,
const NodeEvictionCandidate b 
)
static

Definition at line 907 of file net.cpp.

Referenced by CConnman::AttemptToEvictConnection().

◆ convertSeed6()

static std::vector<CAddress> convertSeed6 ( const std::vector< SeedSpec6 > &  vSeedsIn)
static

Convert the pnSeeds6 array into usable address objects.

Definition at line 131 of file net.cpp.

Referenced by CConnman::ThreadOpenConnections().

◆ Discover()

void Discover ( boost::thread_group &  threadGroup)

Definition at line 2062 of file net.cpp.

Referenced by AppInit2().

◆ GetListenPort()

unsigned short GetListenPort ( )

◆ GetLocal()

bool GetLocal ( CService addr,
const CNetAddr paddrPeer 
)

Definition at line 106 of file net.cpp.

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

◆ GetLocalAddress()

CAddress GetLocalAddress ( const CNetAddr paddrPeer,
ServiceFlags  nLocalServices 
)

Definition at line 155 of file net.cpp.

Referenced by AdvertiseLocal(), and ProcessMessage().

◆ GetNodeSignals()

◆ GetnScore()

int GetnScore ( const CService addr)

Definition at line 167 of file net.cpp.

Referenced by AdvertiseLocal().

◆ IsLimited() [1/2]

bool IsLimited ( enum Network  net)

◆ IsLimited() [2/2]

bool IsLimited ( const CNetAddr addr)

Definition at line 259 of file net.cpp.

◆ IsLocal()

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().

◆ IsPeerAddrLocalGood()

bool IsPeerAddrLocalGood ( CNode pnode)

Definition at line 176 of file net.cpp.

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 285 of file net.cpp.

Referenced by GetNetworksInfo(), IsReachable(), CMasternode::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 292 of file net.cpp.

◆ MapPort()

void MapPort ( bool  )

Definition at line 1511 of file net.cpp.

Referenced by AppInit2(), PrepareShutdown(), and OptionsModel::setData().

◆ PoissonNextSend()

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().

◆ RemoveLocal()

bool RemoveLocal ( const CService addr)

Definition at line 236 of file net.cpp.

Referenced by TorController::disconnected_cb(), and TorController::~TorController().

◆ ReverseCompareNodeMinPingTime()

static bool ReverseCompareNodeMinPingTime ( const NodeEvictionCandidate a,
const NodeEvictionCandidate b 
)
static

Definition at line 884 of file net.cpp.

Referenced by CConnman::AttemptToEvictConnection().

◆ ReverseCompareNodeTimeConnected()

static bool ReverseCompareNodeTimeConnected ( const NodeEvictionCandidate a,
const NodeEvictionCandidate b 
)
static

Definition at line 889 of file net.cpp.

Referenced by CConnman::AttemptToEvictConnection().

◆ SeenLocal()

bool SeenLocal ( const CService addr)

vote for a local address

Definition at line 265 of file net.cpp.

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 245 of file net.cpp.

Referenced by AppInit2(), and TorController::auth_cb().

Variable Documentation

◆ cs_mapLocalHost

◆ cs_mapRelay

CCriticalSection cs_mapRelay

Definition at line 87 of file net.cpp.

Referenced by ProcessGetData(), and CConnman::RelayTransaction().

◆ fDiscover

bool fDiscover = true

Definition at line 76 of file net.cpp.

Referenced by AddLocal(), AppInit2(), CConnman::BindListenPort(), Discover(), and IsPeerAddrLocalGood().

◆ fListen

bool fListen = true

◆ fRelayTxes

bool fRelayTxes = true

Definition at line 78 of file net.cpp.

Referenced by AppInit2(), getnetworkinfo(), and ProcessMessage().

◆ g_signals

CNodeSignals g_signals
static

Definition at line 91 of file net.cpp.

Referenced by GetNodeSignals().

◆ instance_of_cnetcleanup

class CNetCleanup instance_of_cnetcleanup

◆ mapAlreadyAskedFor

limitedmap<uint256, int64_t> mapAlreadyAskedFor(MAX_INV_SZ)

Referenced by CNode::AskFor(), and ProcessMessage().

◆ mapLocalHost

std::map<CNetAddr, LocalServiceInfo> mapLocalHost

Definition at line 80 of file net.cpp.

Referenced by AddLocal(), GetLocal(), getnetworkinfo(), GetnScore(), IsLocal(), RemoveLocal(), and SeenLocal().

◆ mapRelay

std::map<CInv, CDataStream> mapRelay

Definition at line 85 of file net.cpp.

Referenced by ProcessGetData(), and CConnman::RelayTransaction().

◆ NET_MESSAGE_COMMAND_OTHER

const std::string NET_MESSAGE_COMMAND_OTHER = "*other*"
static

Definition at line 68 of file net.cpp.

Referenced by CNode::CNode(), and CNode::ReceiveMsgBytes().

◆ pnodeLocalHost

CNode* pnodeLocalHost = NULL
static

Definition at line 82 of file net.cpp.

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

◆ strSubVersion

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().

◆ vfLimited

bool vfLimited[NET_MAX] = {}
static

Definition at line 81 of file net.cpp.

Referenced by IsLimited(), IsReachable(), and SetLimited().

◆ vRelayExpiration

std::deque<pair<int64_t, CInv> > vRelayExpiration

Definition at line 86 of file net.cpp.

Referenced by CConnman::RelayTransaction().