PRCYCoin  2.0.0.7rc1
P2P Digital Currency
Classes | Macros | Functions | Variables
net.cpp File Reference
#include "net.h"
#include "addrman.h"
#include "chainparams.h"
#include "clientversion.h"
#include "crypto/common.h"
#include "guiinterface.h"
#include "main.h"
#include "primitives/transaction.h"
#include "netbase.h"
#include "scheduler.h"
#include <fcntl.h>
#include <boost/thread.hpp>
#include <math.h>
Include dependency graph for net.cpp:

Go to the source code of this file.

Classes

struct  NodeEvictionCandidate
 
class  CompareNetGroupKeyed
 
class  CNetCleanup
 

Macros

#define DUMP_ADDRESSES_INTERVAL   900
 
#define FEELER_SLEEP_WINDOW   1
 
#define X(name)   stats.name = name
 

Functions

CNodeSignalsGetNodeSignals ()
 
void AddOneShot (std::string strDest)
 
unsigned short GetListenPort ()
 
bool GetLocal (CService &addr, const CNetAddr *paddrPeer)
 
CAddress GetLocalAddress (const CNetAddr *paddrPeer)
 
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...
 
void AddressCurrentlyConnected (const CService &addr)
 
CNodeFindNode (const CNetAddr &ip)
 
CNodeFindNode (const CSubNet &subNet)
 
CNodeFindNode (const std::string &addrName)
 
CNodeFindNode (const CService &addr)
 
CNodeConnectNode (CAddress addrConnect, const char *pszDest, bool fCountFailure)
 
void SocketSendData (CNode *pnode)
 
void ThreadSocketHandler ()
 
void MapPort (bool)
 
void ThreadDNSAddressSeed ()
 
void DumpAddresses ()
 
void DumpData ()
 
void ThreadOpenConnections ()
 
std::vector< AddedNodeInfoGetAddedNodeInfo ()
 
void ThreadOpenAddedConnections ()
 
bool OpenNetworkConnection (const CAddress &addrConnect, bool fCountFailure, CSemaphoreGrant *grantOutbound, const char *pszDest, bool fOneShot, bool fFeeler)
 
void ThreadMessageHandler ()
 
bool BindListenPort (const CService &addrBind, std::string &strError, bool fWhitelisted)
 
void StartNode (boost::thread_group &threadGroup, CScheduler &scheduler)
 
bool StopNode ()
 
void RelayTransaction (const CTransaction &tx)
 
void RelayTransaction (const CTransaction &tx, const CDataStream &ss)
 
void RelayTransactionLockReq (const CTransaction &tx, bool relayToAll)
 
void RelayInv (CInv &inv)
 
unsigned int ReceiveFloodSize ()
 
unsigned int SendBufferSize ()
 
bool validateMasternodeIP (const std::string &addrStr)
 
int64_t PoissonNextSend (int64_t nNow, int average_interval_seconds)
 Return a timestamp in the future (in microseconds) for exponentially distributed events. More...
 

Variables

bool fDiscover = true
 
bool fListen = true
 
ServiceFlags nLocalServices = NODE_NETWORK
 
RecursiveMutex cs_mapLocalHost
 
std::map< CNetAddr, LocalServiceInfomapLocalHost
 
uint64_t nLocalHostNonce = 0
 
CAddrMan addrman
 
int nMaxConnections = DEFAULT_MAX_PEER_CONNECTIONS
 
bool fAddressesInitialized = false
 
std::string strSubVersion
 Subversion as sent to the P2P network in version messages. More...
 
std::vector< CNode * > vNodes
 
RecursiveMutex cs_vNodes
 
std::map< CInv, CDataStreammapRelay
 
std::deque< std::pair< int64_t, CInv > > vRelayExpiration
 
RecursiveMutex cs_mapRelay
 
limitedmap< CInv, int64_t > mapAlreadyAskedFor (MAX_INV_SZ)
 
RecursiveMutex cs_vOneShots
 
std::vector< std::string > vAddedNodes
 
RecursiveMutex cs_vAddedNodes
 
NodeId nLastNodeId = 0
 
RecursiveMutex cs_nLastNodeId
 
boost::condition_variable messageHandlerCondition
 
class CNetCleanup instance_of_cnetcleanup
 

Macro Definition Documentation

◆ DUMP_ADDRESSES_INTERVAL

#define DUMP_ADDRESSES_INTERVAL   900

Definition at line 44 of file net.cpp.

◆ FEELER_SLEEP_WINDOW

#define FEELER_SLEEP_WINDOW   1

Definition at line 47 of file net.cpp.

◆ X

#define X (   name)    stats.name = name

Definition at line 639 of file net.cpp.

Function Documentation

◆ AddLocal() [1/2]

bool AddLocal ( const CNetAddr addr,
int  nScore 
)

Definition at line 233 of file net.cpp.

Here is the call graph for this function:

◆ AddLocal() [2/2]

bool AddLocal ( const CService addr,
int  nScore 
)

Definition at line 208 of file net.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AddOneShot()

void AddOneShot ( std::string  strDest)

Definition at line 109 of file net.cpp.

Here is the caller graph for this function:

◆ AddressCurrentlyConnected()

void AddressCurrentlyConnected ( const CService addr)

Definition at line 291 of file net.cpp.

Here is the call graph for this function:

◆ AdvertiseLocal()

void AdvertiseLocal ( CNode pnode)

Definition at line 188 of file net.cpp.

Here is the call graph for this function:

◆ BindListenPort()

bool BindListenPort ( const CService addrBind,
std::string &  strError,
bool  fWhitelisted 
)

Definition at line 1757 of file net.cpp.

Here is the call graph for this function:

◆ ConnectNode()

CNode* ConnectNode ( CAddress  addrConnect,
const char *  pszDest,
bool  fCountFailure 
)

debug print

Definition at line 342 of file net.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DumpAddresses()

void DumpAddresses ( )

Definition at line 1429 of file net.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DumpData()

void DumpData ( )

Definition at line 1439 of file net.cpp.

Here is the call graph for this function:

◆ FindNode() [1/4]

CNode* FindNode ( const CNetAddr ip)

Definition at line 301 of file net.cpp.

Here is the caller graph for this function:

◆ FindNode() [2/4]

CNode* FindNode ( const CService addr)

Definition at line 325 of file net.cpp.

Here is the call graph for this function:

◆ FindNode() [3/4]

CNode* FindNode ( const CSubNet subNet)

Definition at line 309 of file net.cpp.

Here is the call graph for this function:

◆ FindNode() [4/4]

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

Definition at line 317 of file net.cpp.

◆ GetAddedNodeInfo()

std::vector<AddedNodeInfo> GetAddedNodeInfo ( )

Definition at line 1593 of file net.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetListenPort()

unsigned short GetListenPort ( )

Definition at line 114 of file net.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetLocal()

bool GetLocal ( CService addr,
const CNetAddr paddrPeer 
)

Definition at line 119 of file net.cpp.

Here is the caller graph for this function:

◆ GetLocalAddress()

CAddress GetLocalAddress ( const CNetAddr paddrPeer)

Definition at line 164 of file net.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetNodeSignals()

CNodeSignals& GetNodeSignals ( )

Definition at line 107 of file net.cpp.

Here is the caller graph for this function:

◆ GetnScore()

int GetnScore ( const CService addr)

Definition at line 174 of file net.cpp.

Here is the caller graph for this function:

◆ IsLimited() [1/2]

bool IsLimited ( const CNetAddr addr)

Definition at line 257 of file net.cpp.

Here is the call graph for this function:

◆ IsLimited() [2/2]

bool IsLimited ( enum Network  net)

Definition at line 252 of file net.cpp.

Here is the caller graph for this function:

◆ IsLocal()

bool IsLocal ( const CService addr)

check whether a given address is potentially local

Definition at line 274 of file net.cpp.

Here is the caller graph for this function:

◆ IsPeerAddrLocalGood()

bool IsPeerAddrLocalGood ( CNode pnode)

Definition at line 182 of file net.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsReachable() [1/2]

bool IsReachable ( const CNetAddr addr)

check whether a given address is in a network we can probably connect to

Definition at line 286 of file net.cpp.

Here is the call graph for this function:

◆ IsReachable() [2/2]

bool IsReachable ( enum Network  net)

check whether a given network is one we can probably connect to

Definition at line 280 of file net.cpp.

Here is the caller graph for this function:

◆ MapPort()

void MapPort ( bool  )

Definition at line 1360 of file net.cpp.

Here is the caller graph for this function:

◆ OpenNetworkConnection()

bool OpenNetworkConnection ( const CAddress addrConnect,
bool  fCountFailure,
CSemaphoreGrant grantOutbound,
const char *  pszDest,
bool  fOneShot,
bool  fFeeler 
)

Definition at line 1670 of file net.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

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

Here is the call graph for this function:

◆ ReceiveFloodSize()

unsigned int ReceiveFloodSize ( )

Definition at line 2241 of file net.cpp.

Here is the call graph for this function:

◆ RelayInv()

void RelayInv ( CInv inv)

Definition at line 2077 of file net.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RelayTransaction() [1/2]

void RelayTransaction ( const CTransaction tx)

Definition at line 2028 of file net.cpp.

Here is the caller graph for this function:

◆ RelayTransaction() [2/2]

void RelayTransaction ( const CTransaction tx,
const CDataStream ss 
)

Definition at line 2035 of file net.cpp.

Here is the call graph for this function:

◆ RelayTransactionLockReq()

void RelayTransactionLockReq ( const CTransaction tx,
bool  relayToAll 
)

Definition at line 2063 of file net.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RemoveLocal()

bool RemoveLocal ( const CService addr)

Definition at line 237 of file net.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SeenLocal()

bool SeenLocal ( const CService addr)

vote for a local address

Definition at line 262 of file net.cpp.

◆ SendBufferSize()

unsigned int SendBufferSize ( )

Definition at line 2243 of file net.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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.

Here is the caller graph for this function:

◆ SocketSendData()

void SocketSendData ( CNode pnode)

Definition at line 762 of file net.cpp.

◆ StartNode()

void StartNode ( boost::thread_group &  threadGroup,
CScheduler scheduler 
)

Definition at line 1891 of file net.cpp.

◆ StopNode()

bool StopNode ( )

Definition at line 1972 of file net.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ThreadDNSAddressSeed()

void ThreadDNSAddressSeed ( )
Todo:
: The seed name resolve may fail, yielding an IP of [::], which results in

Definition at line 1377 of file net.cpp.

Here is the call graph for this function:

◆ ThreadMessageHandler()

void ThreadMessageHandler ( )

Definition at line 1700 of file net.cpp.

Here is the call graph for this function:

◆ ThreadOpenAddedConnections()

void ThreadOpenAddedConnections ( )

Definition at line 1645 of file net.cpp.

Here is the call graph for this function:

◆ ThreadOpenConnections()

void ThreadOpenConnections ( )

Definition at line 1461 of file net.cpp.

◆ ThreadSocketHandler()

void ThreadSocketHandler ( )

Definition at line 1006 of file net.cpp.

Here is the call graph for this function:

◆ validateMasternodeIP()

bool validateMasternodeIP ( const std::string &  addrStr)

Definition at line 2493 of file net.cpp.

Here is the call graph for this function:

Variable Documentation

◆ addrman

CAddrMan addrman

Definition at line 80 of file net.cpp.

◆ cs_mapLocalHost

RecursiveMutex cs_mapLocalHost

Definition at line 74 of file net.cpp.

◆ cs_mapRelay

RecursiveMutex cs_mapRelay

Definition at line 89 of file net.cpp.

◆ cs_nLastNodeId

RecursiveMutex cs_nLastNodeId

Definition at line 99 of file net.cpp.

◆ cs_vAddedNodes

RecursiveMutex cs_vAddedNodes

Definition at line 96 of file net.cpp.

◆ cs_vNodes

RecursiveMutex cs_vNodes

Definition at line 86 of file net.cpp.

◆ cs_vOneShots

RecursiveMutex cs_vOneShots

Definition at line 93 of file net.cpp.

◆ fAddressesInitialized

bool fAddressesInitialized = false

Definition at line 82 of file net.cpp.

◆ fDiscover

bool fDiscover = true

Definition at line 71 of file net.cpp.

◆ fListen

bool fListen = true

Definition at line 72 of file net.cpp.

◆ instance_of_cnetcleanup

class CNetCleanup instance_of_cnetcleanup

◆ mapAlreadyAskedFor

limitedmap<CInv, int64_t> mapAlreadyAskedFor(MAX_INV_SZ)

◆ mapLocalHost

std::map<CNetAddr, LocalServiceInfo> mapLocalHost

Definition at line 75 of file net.cpp.

◆ mapRelay

std::map<CInv, CDataStream> mapRelay

Definition at line 87 of file net.cpp.

◆ messageHandlerCondition

boost::condition_variable messageHandlerCondition

Definition at line 102 of file net.cpp.

◆ nLastNodeId

NodeId nLastNodeId = 0

Definition at line 98 of file net.cpp.

◆ nLocalHostNonce

uint64_t nLocalHostNonce = 0

Definition at line 78 of file net.cpp.

◆ nLocalServices

ServiceFlags nLocalServices = NODE_NETWORK

Definition at line 73 of file net.cpp.

◆ nMaxConnections

int nMaxConnections = DEFAULT_MAX_PEER_CONNECTIONS

Definition at line 81 of file net.cpp.

◆ strSubVersion

std::string strSubVersion

Subversion as sent to the P2P network in version messages.

Definition at line 83 of file net.cpp.

◆ vAddedNodes

std::vector<std::string> vAddedNodes

Definition at line 95 of file net.cpp.

◆ vNodes

std::vector<CNode*> vNodes

Definition at line 85 of file net.cpp.

◆ vRelayExpiration

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

Definition at line 88 of file net.cpp.