PIVX Core  5.6.99
P2P Digital Currency
Classes | Macros | Typedefs | Enumerations | Functions | Variables
net.h File Reference
#include "addrdb.h"
#include "addrman.h"
#include "bloom.h"
#include "compat.h"
#include "crypto/siphash.h"
#include "fs.h"
#include "hash.h"
#include "limitedmap.h"
#include "netaddress.h"
#include "protocol.h"
#include "random.h"
#include "streams.h"
#include "sync.h"
#include "uint256.h"
#include "utilstrencodings.h"
#include "threadinterrupt.h"
#include "validation.h"
#include <atomic>
#include <cstdint>
#include <deque>
#include <thread>
#include <memory>
#include <condition_variable>
#include <arpa/inet.h>
Include dependency graph for net.h:
This graph shows which files directly or indirectly include this file:

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
 
struct  LocalServiceInfo
 
class  CNodeStats
 
class  CNetMessage
 
class  CNode
 Information about a peer. More...
 
class  CExplicitNetCleanup
 
class  NetEventsInterface
 Interface for message handling. More...
 

Macros

#define DEFAULT_ALLOW_OPTIMISTIC_SEND   false
 
#define USE_WAKEUP_PIPE
 
#define ENOUGH_CONNECTIONS   2
 Disconnected peers are added to setOffsetDisconnectedPeers only if node has less than ENOUGH_CONNECTIONS. More...
 
#define MAX_TIMEOFFSET_DISCONNECTIONS   16
 Maximum number of peers added to setOffsetDisconnectedPeers before triggering a warning. More...
 

Typedefs

typedef int NodeId
 
typedef std::map< std::string, uint64_t > mapMsgCmdSize
 

Enumerations

enum  {
  LOCAL_NONE , LOCAL_IF , LOCAL_BIND , LOCAL_MAPPED ,
  LOCAL_MANUAL , LOCAL_MAX
}
 

Functions

void Discover ()
 
uint16_t GetListenPort ()
 
bool BindListenPort (const CService &bindAddr, std::string &strError, bool fWhitelisted=false)
 
void CheckOffsetDisconnectedPeers (const CNetAddr &ip)
 
bool IsPeerAddrLocalGood (CNode *pnode)
 
void AdvertiseLocal (CNode *pnode)
 
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 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)
 
CAddress GetLocalAddress (const CNetAddr *paddrPeer, ServiceFlags nLocalServices)
 
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...
 
std::chrono::microseconds PoissonNextSend (std::chrono::microseconds now, std::chrono::seconds average_interval)
 Wrapper to return mockable type. More...
 

Variables

std::unique_ptr< CConnmang_connman
 
bool fDiscover
 
bool fListen
 
limitedmap< CInv, int64_t > mapAlreadyAskedFor
 
std::string strSubVersion
 Subversion as sent to the P2P network in version messages. More...
 
RecursiveMutex cs_mapLocalHost
 
std::map< CNetAddr, LocalServiceInfomapLocalHost
 

Macro Definition Documentation

◆ DEFAULT_ALLOW_OPTIMISTIC_SEND

#define DEFAULT_ALLOW_OPTIMISTIC_SEND   false

Definition at line 49 of file net.h.

◆ ENOUGH_CONNECTIONS

#define ENOUGH_CONNECTIONS   2

Disconnected peers are added to setOffsetDisconnectedPeers only if node has less than ENOUGH_CONNECTIONS.

Definition at line 96 of file net.h.

◆ MAX_TIMEOFFSET_DISCONNECTIONS

#define MAX_TIMEOFFSET_DISCONNECTIONS   16

Maximum number of peers added to setOffsetDisconnectedPeers before triggering a warning.

Definition at line 98 of file net.h.

◆ USE_WAKEUP_PIPE

#define USE_WAKEUP_PIPE

Definition at line 50 of file net.h.

Typedef Documentation

◆ mapMsgCmdSize

typedef std::map<std::string, uint64_t> mapMsgCmdSize

Definition at line 583 of file net.h.

◆ NodeId

typedef int NodeId

Definition at line 109 of file net.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
LOCAL_NONE 
LOCAL_IF 
LOCAL_BIND 
LOCAL_MAPPED 
LOCAL_MANUAL 
LOCAL_MAX 

Definition at line 534 of file net.h.

Function Documentation

◆ AddLocal() [1/2]

bool AddLocal ( const CNetAddr addr,
int  nScore = LOCAL_NONE 
)

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 = LOCAL_NONE 
)

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:

◆ BindListenPort()

bool BindListenPort ( const CService bindAddr,
std::string &  strError,
bool  fWhitelisted = false 
)

◆ 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 = nullptr 
)

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:

◆ 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() [1/2]

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:

◆ PoissonNextSend() [2/2]

std::chrono::microseconds PoissonNextSend ( std::chrono::microseconds  now,
std::chrono::seconds  average_interval 
)
inline

Wrapper to return mockable type.

Definition at line 971 of file net.h.

Here is the call 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
extern

Definition at line 91 of file net.cpp.

◆ fDiscover

bool fDiscover
extern

Definition at line 89 of file net.cpp.

◆ fListen

bool fListen
extern

Definition at line 90 of file net.cpp.

◆ g_connman

std::unique_ptr<CConnman> g_connman
extern

Definition at line 90 of file init.cpp.

◆ mapAlreadyAskedFor

limitedmap<CInv, int64_t> mapAlreadyAskedFor
extern

◆ mapLocalHost

std::map<CNetAddr, LocalServiceInfo> mapLocalHost
extern

Definition at line 92 of file net.cpp.

◆ strSubVersion

std::string strSubVersion
extern

Subversion as sent to the P2P network in version messages.

Definition at line 94 of file net.cpp.