PIVX Core  5.6.99
P2P Digital Currency
Classes | Macros | Enumerations | Functions | Variables
net.cpp File Reference
#include "net.h"
#include "chainparams.h"
#include "clientversion.h"
#include "crypto/common.h"
#include "crypto/sha256.h"
#include "guiinterface.h"
#include "netaddress.h"
#include "netbase.h"
#include "netmessagemaker.h"
#include "optional.h"
#include "primitives/transaction.h"
#include "scheduler.h"
#include "tiertwo/net_masternodes.h"
#include <fcntl.h>
#include <cstdint>
#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 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

uint16_t GetListenPort ()
 
bool GetLocal (CService &addr, const CNetAddr *paddrPeer)
 
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 SetReachable (enum Network net, bool reachable)
 Mark a network as reachable or unreachable (no automatic connects to it) More...
 
bool IsReachable (enum Network net)
 
bool IsReachable (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...
 
void CheckOffsetDisconnectedPeers (const CNetAddr &ip)
 
void Discover ()
 
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
 
RecursiveMutex cs_mapLocalHost
 
std::map< CNetAddr, LocalServiceInfomapLocalHost
 
std::string strSubVersion
 Subversion as sent to the P2P network in version messages. More...
 
limitedmap< CInv, int64_t > mapAlreadyAskedFor (MAX_INV_SZ)
 
class CNetCleanup instance_of_cnetcleanup
 

Macro Definition Documentation

◆ DUMP_ADDRESSES_INTERVAL

#define DUMP_ADDRESSES_INTERVAL   900

Definition at line 47 of file net.cpp.

◆ FEELER_SLEEP_WINDOW

#define FEELER_SLEEP_WINDOW   1

Definition at line 50 of file net.cpp.

◆ X

#define X (   name)    stats.name = name

Definition at line 664 of file net.cpp.

Enumeration Type Documentation

◆ BindFlags

enum BindFlags

Used to pass flags to the Bind() function.

Todo:
: Can be removed when our pull-tester is upgraded to a modern MinGW version.
Enumerator
BF_NONE 
BF_EXPLICIT 
BF_REPORT_ERROR 
BF_WHITELIST 

Definition at line 68 of file net.cpp.

Function Documentation

◆ AddLocal() [1/2]

bool AddLocal ( const CNetAddr addr,
int  nScore 
)

Definition at line 232 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 206 of file net.cpp.

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

◆ AdvertiseLocal()

void AdvertiseLocal ( CNode pnode)

Definition at line 186 of file net.cpp.

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

◆ CheckOffsetDisconnectedPeers()

void CheckOffsetDisconnectedPeers ( const CNetAddr ip)

Definition at line 908 of file net.cpp.

Here is the call graph for this function:

◆ Discover()

void Discover ( )

Definition at line 2101 of file net.cpp.

Here is the call graph for this function:

◆ GetListenPort()

uint16_t GetListenPort ( )

Definition at line 104 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 110 of file net.cpp.

Here is the caller graph for this function:

◆ GetLocalAddress()

CAddress GetLocalAddress ( const CNetAddr paddrPeer,
ServiceFlags  nLocalServices 
)

Definition at line 158 of file net.cpp.

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

◆ GetnScore()

int GetnScore ( const CService addr)

Definition at line 169 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 278 of file net.cpp.

Here is the caller graph for this function:

◆ IsPeerAddrLocalGood()

bool IsPeerAddrLocalGood ( CNode pnode)

Definition at line 178 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)
Returns
true if the address is in a reachable network, false otherwise

Definition at line 259 of file net.cpp.

Here is the call graph for this function:

◆ IsReachable() [2/2]

bool IsReachable ( enum Network  net)
Returns
true if the network is reachable, false otherwise

Definition at line 253 of file net.cpp.

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 2846 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 caller graph for this function:

◆ SeenLocal()

bool SeenLocal ( const CService addr)

vote for a local address

Definition at line 265 of file net.cpp.

◆ SetReachable()

void SetReachable ( enum Network  net,
bool  reachable 
)

Mark a network as reachable or unreachable (no automatic connects to it)

Note
Networks are reachable by default

Definition at line 245 of file net.cpp.

Here is the caller graph for this function:

◆ validateMasternodeIP()

bool validateMasternodeIP ( const std::string &  addrStr)

Definition at line 2836 of file net.cpp.

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

Variable Documentation

◆ cs_mapLocalHost

RecursiveMutex cs_mapLocalHost

Definition at line 91 of file net.cpp.

◆ fDiscover

bool fDiscover = true

Definition at line 89 of file net.cpp.

◆ fListen

bool fListen = true

Definition at line 90 of file net.cpp.

◆ instance_of_cnetcleanup

class CNetCleanup instance_of_cnetcleanup

◆ mapAlreadyAskedFor

limitedmap<CInv, int64_t> mapAlreadyAskedFor(MAX_INV_SZ) ( MAX_INV_SZ  )

◆ mapLocalHost

std::map<CNetAddr, LocalServiceInfo> mapLocalHost

Definition at line 92 of file net.cpp.

◆ strSubVersion

std::string strSubVersion

Subversion as sent to the P2P network in version messages.

Definition at line 94 of file net.cpp.