Bitcoin
Classes | Typedefs | Enumerations | Functions | Variables
net.h File Reference
#include <addrdb.h>
#include <addrman.h>
#include <amount.h>
#include <bloom.h>
#include <compat.h>
#include <crypto/siphash.h>
#include <hash.h>
#include <limitedmap.h>
#include <netaddress.h>
#include <policy/feerate.h>
#include <protocol.h>
#include <random.h>
#include <streams.h>
#include <sync.h>
#include <uint256.h>
#include <threadinterrupt.h>
#include <atomic>
#include <deque>
#include <stdint.h>
#include <thread>
#include <memory>
#include <condition_variable>
#include <arpa/inet.h>

Go to the source code of this file.

Classes

struct  AddedNodeInfo
 
struct  CSerializedNetMsg
 
class  CConnman
 
struct  CConnman::Options
 
struct  CConnman::ListenSocket
 
struct  CombinerAll
 
class  NetEventsInterface
 
struct  LocalServiceInfo
 
class  CNodeStats
 
class  CNetMessage
 
class  CNode
 

Typedefs

typedef int64_t NodeId
 
typedef std::map< std::string, uint64_tmapMsgCmdSize
 

Enumerations

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

Functions

void Discover ()
 
void StartMapPort ()
 
void InterruptMapPort ()
 
void StopMapPort ()
 
unsigned short GetListenPort ()
 
bool BindListenPort (const CService &bindAddr, std::string &strError, bool fWhitelisted=false)
 
bool IsPeerAddrLocalGood (CNode *pnode)
 
void AdvertiseLocal (CNode *pnode)
 
void SetReachable (enum Network net, bool reachable)
 
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)
 
void RemoveLocal (const CService &addr)
 
bool SeenLocal (const CService &addr)
 
bool IsLocal (const CService &addr)
 
bool GetLocal (CService &addr, const CNetAddr *paddrPeer=nullptr)
 
CAddress GetLocalAddress (const CNetAddr *paddrPeer, ServiceFlags nLocalServices)
 
std::map< CNetAddr, LocalServiceInfo > mapLocalHost GUARDED_BY (cs_mapLocalHost)
 
int64_t PoissonNextSend (int64_t now, int average_interval_seconds)
 

Variables

static const int PING_INTERVAL = 2 * 60
 
static const int TIMEOUT_INTERVAL = 20 * 60
 
static const int FEELER_INTERVAL = 120
 
static const unsigned int MAX_INV_SZ = 50000
 
static const unsigned int MAX_LOCATOR_SZ = 101
 
static const unsigned int MAX_ADDR_TO_SEND = 1000
 
static const unsigned int MAX_PROTOCOL_MESSAGE_LENGTH = 4 * 1000 * 1000
 
static const unsigned int MAX_SUBVERSION_LENGTH = 256
 
static const int MAX_OUTBOUND_CONNECTIONS = 8
 
static const int MAX_ADDNODE_CONNECTIONS = 8
 
static const bool DEFAULT_LISTEN = true
 
static const bool DEFAULT_UPNP = false
 
static const unsigned int DEFAULT_MAX_PEER_CONNECTIONS = 125
 
static const uint64_t DEFAULT_MAX_UPLOAD_TARGET = 0
 
static const uint64_t MAX_UPLOAD_TIMEFRAME = 60 * 60 * 24
 
static const bool DEFAULT_BLOCKSONLY = false
 
static const int64_t DEFAULT_PEER_CONNECT_TIMEOUT = 60
 
static const bool DEFAULT_FORCEDNSSEED = false
 
static const size_t DEFAULT_MAXRECEIVEBUFFER = 5 * 1000
 
static const size_t DEFAULT_MAXSENDBUFFER = 1 * 1000
 
std::unique_ptr< CConnmang_connman
 
std::unique_ptr< BanMang_banman
 
bool fDiscover
 
bool fListen
 
bool g_relay_txes
 
std::string strSubVersion
 
CCriticalSection cs_mapLocalHost
 
const std::string NET_MESSAGE_COMMAND_OTHER
 

Typedef Documentation

◆ mapMsgCmdSize

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

◆ NodeId

typedef int64_t NodeId

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
LOCAL_NONE 
LOCAL_IF 
LOCAL_BIND 
LOCAL_UPNP 
LOCAL_MANUAL 
LOCAL_MAX 

Function Documentation

◆ AddLocal() [1/2]

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

◆ AddLocal() [2/2]

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

◆ AdvertiseLocal()

void AdvertiseLocal ( CNode pnode)

◆ BindListenPort()

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

◆ Discover()

void Discover ( )

◆ GetListenPort()

unsigned short GetListenPort ( )

◆ GetLocal()

bool GetLocal ( CService addr,
const CNetAddr paddrPeer = nullptr 
)

◆ GetLocalAddress()

CAddress GetLocalAddress ( const CNetAddr paddrPeer,
ServiceFlags  nLocalServices 
)

◆ GUARDED_BY()

std::map<CNetAddr, LocalServiceInfo> mapLocalHost GUARDED_BY ( cs_mapLocalHost  )

◆ InterruptMapPort()

void InterruptMapPort ( )

◆ IsLocal()

bool IsLocal ( const CService addr)

check whether a given address is potentially local

◆ IsPeerAddrLocalGood()

bool IsPeerAddrLocalGood ( CNode pnode)

◆ IsReachable() [1/2]

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

◆ IsReachable() [2/2]

bool IsReachable ( const CNetAddr addr)
Returns
true if the address is in a reachable network, false otherwise

◆ PoissonNextSend()

int64_t PoissonNextSend ( int64_t  now,
int  average_interval_seconds 
)

Return a timestamp in the future (in microseconds) for exponentially distributed events.

◆ RemoveLocal()

void RemoveLocal ( const CService addr)

◆ SeenLocal()

bool SeenLocal ( const CService addr)

vote for a local address

◆ 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

◆ StartMapPort()

void StartMapPort ( )

◆ StopMapPort()

void StopMapPort ( )

Variable Documentation

◆ cs_mapLocalHost

CCriticalSection cs_mapLocalHost

◆ DEFAULT_BLOCKSONLY

const bool DEFAULT_BLOCKSONLY = false
static

Default for blocks only

◆ DEFAULT_FORCEDNSSEED

const bool DEFAULT_FORCEDNSSEED = false
static

◆ DEFAULT_LISTEN

const bool DEFAULT_LISTEN = true
static

-listen default

◆ DEFAULT_MAX_PEER_CONNECTIONS

const unsigned int DEFAULT_MAX_PEER_CONNECTIONS = 125
static

The maximum number of peer connections to maintain.

◆ DEFAULT_MAX_UPLOAD_TARGET

const uint64_t DEFAULT_MAX_UPLOAD_TARGET = 0
static

The default for -maxuploadtarget. 0 = Unlimited

◆ DEFAULT_MAXRECEIVEBUFFER

const size_t DEFAULT_MAXRECEIVEBUFFER = 5 * 1000
static

◆ DEFAULT_MAXSENDBUFFER

const size_t DEFAULT_MAXSENDBUFFER = 1 * 1000
static

◆ DEFAULT_PEER_CONNECT_TIMEOUT

const int64_t DEFAULT_PEER_CONNECT_TIMEOUT = 60
static

-peertimeout default

◆ DEFAULT_UPNP

const bool DEFAULT_UPNP = false
static

-upnp default

◆ fDiscover

bool fDiscover

◆ FEELER_INTERVAL

const int FEELER_INTERVAL = 120
static

Run the feeler connection loop once every 2 minutes or 120 seconds.

◆ fListen

bool fListen

◆ g_banman

std::unique_ptr<BanMan> g_banman

◆ g_connman

std::unique_ptr<CConnman> g_connman

◆ g_relay_txes

bool g_relay_txes

◆ MAX_ADDNODE_CONNECTIONS

const int MAX_ADDNODE_CONNECTIONS = 8
static

Maximum number of addnode outgoing nodes

◆ MAX_ADDR_TO_SEND

const unsigned int MAX_ADDR_TO_SEND = 1000
static

The maximum number of new addresses to accumulate before announcing.

◆ MAX_INV_SZ

const unsigned int MAX_INV_SZ = 50000
static

The maximum number of entries in an 'inv' protocol message

◆ MAX_LOCATOR_SZ

const unsigned int MAX_LOCATOR_SZ = 101
static

The maximum number of entries in a locator

◆ MAX_OUTBOUND_CONNECTIONS

const int MAX_OUTBOUND_CONNECTIONS = 8
static

Maximum number of automatic outgoing nodes

◆ MAX_PROTOCOL_MESSAGE_LENGTH

const unsigned int MAX_PROTOCOL_MESSAGE_LENGTH = 4 * 1000 * 1000
static

Maximum length of incoming protocol messages (no message over 4 MB is currently acceptable).

◆ MAX_SUBVERSION_LENGTH

const unsigned int MAX_SUBVERSION_LENGTH = 256
static

Maximum length of the user agent string in version message

◆ MAX_UPLOAD_TIMEFRAME

const uint64_t MAX_UPLOAD_TIMEFRAME = 60 * 60 * 24
static

The default timeframe for -maxuploadtarget. 1 day.

◆ NET_MESSAGE_COMMAND_OTHER

const std::string NET_MESSAGE_COMMAND_OTHER

◆ PING_INTERVAL

const int PING_INTERVAL = 2 * 60
static

Time between pings automatically sent out for latency probing and keepalive (in seconds).

◆ strSubVersion

std::string strSubVersion

Subversion as sent to the P2P network in version messages

◆ TIMEOUT_INTERVAL

const int TIMEOUT_INTERVAL = 20 * 60
static

Time after which to disconnect, after waiting for a ping response (or inactivity).