![]() |
Bitcoin Core
21.99.0
P2P Digital Currency
|
#include <net.h>
#include <banman.h>
#include <clientversion.h>
#include <consensus/consensus.h>
#include <crypto/sha256.h>
#include <net_permissions.h>
#include <netbase.h>
#include <node/ui_interface.h>
#include <optional.h>
#include <protocol.h>
#include <random.h>
#include <scheduler.h>
#include <util/strencodings.h>
#include <util/translation.h>
#include <fcntl.h>
#include <algorithm>
#include <cstdint>
#include <unordered_map>
#include <math.h>
Go to the source code of this file.
Classes | |
class | CNetCleanup |
Macros | |
#define | FEELER_SLEEP_WINDOW 1 |
#define | MSG_NOSIGNAL 0 |
#define | MSG_DONTWAIT 0 |
#define | X(name) stats.name = name |
Enumerations | |
enum | BindFlags { BF_NONE = 0, BF_EXPLICIT = (1U << 0), BF_REPORT_ERROR = (1U << 1), BF_DONT_ADVERTISE = (1U << 2) } |
Used to pass flags to the Bind() function. More... | |
Functions | |
std::map< CNetAddr, LocalServiceInfo > mapLocalHost | GUARDED_BY (cs_mapLocalHost) |
uint16_t | GetListenPort () |
bool | GetLocal (CService &addr, const CNetAddr *paddrPeer) |
static std::vector< CAddress > | convertSeed6 (const std::vector< SeedSpec6 > &vSeedsIn) |
Convert the pnSeed6 array into usable address objects. More... | |
CAddress | GetLocalAddress (const CNetAddr *paddrPeer, ServiceFlags nLocalServices) |
static 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) |
void | 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... | |
static CAddress | GetBindAddress (SOCKET sock) |
Get the bind address for a socket as CAddress. More... | |
std::string | ConnectionTypeAsString (ConnectionType conn_type) |
Convert ConnectionType enum to a string value. More... | |
static bool | ReverseCompareNodeMinPingTime (const NodeEvictionCandidate &a, const NodeEvictionCandidate &b) |
static bool | ReverseCompareNodeTimeConnected (const NodeEvictionCandidate &a, const NodeEvictionCandidate &b) |
static bool | CompareLocalHostTimeConnected (const NodeEvictionCandidate &a, const NodeEvictionCandidate &b) |
static bool | CompareNetGroupKeyed (const NodeEvictionCandidate &a, const NodeEvictionCandidate &b) |
static bool | CompareNodeBlockTime (const NodeEvictionCandidate &a, const NodeEvictionCandidate &b) |
static bool | CompareNodeTXTime (const NodeEvictionCandidate &a, const NodeEvictionCandidate &b) |
static bool | CompareNodeBlockRelayOnlyTime (const NodeEvictionCandidate &a, const NodeEvictionCandidate &b) |
template<typename T , typename Comparator > | |
static void | EraseLastKElements (std::vector< T > &elements, Comparator comparator, size_t k) |
Sort an array by the specified comparator, then erase the last K elements. More... | |
Optional< NodeId > | SelectNodeToEvict (std::vector< NodeEvictionCandidate > &&vEvictionCandidates) |
void | Discover () |
int64_t | PoissonNextSend (int64_t now, int average_interval_seconds) |
Return a timestamp in the future (in microseconds) for exponentially distributed events. More... | |
Variables | |
static constexpr size_t | MAX_BLOCK_RELAY_ONLY_ANCHORS = 2 |
Maximum number of block-relay-only anchor connections. More... | |
const char *const | ANCHORS_DATABASE_FILENAME = "anchors.dat" |
Anchor IP address database file name. More... | |
static constexpr std::chrono::minutes | DUMP_PEERS_INTERVAL {15} |
static constexpr int | DNSSEEDS_TO_QUERY_AT_ONCE = 3 |
Number of DNS seeds to query when the number of connections is low. More... | |
static constexpr std::chrono::seconds | DNSSEEDS_DELAY_FEW_PEERS {11} |
How long to delay before querying DNS seeds. More... | |
static constexpr std::chrono::minutes | DNSSEEDS_DELAY_MANY_PEERS {5} |
static constexpr int | DNSSEEDS_DELAY_PEER_THRESHOLD = 1000 |
static constexpr std::chrono::seconds | MAX_UPLOAD_TIMEFRAME {60 * 60 * 24} |
The default timeframe for -maxuploadtarget. More... | |
static const uint64_t | SELECT_TIMEOUT_MILLISECONDS = 50 |
const std::string | NET_MESSAGE_COMMAND_OTHER = "*other*" |
static const uint64_t | RANDOMIZER_ID_NETGROUP = 0x6c0edd8036ef4036ULL |
static const uint64_t | RANDOMIZER_ID_LOCALHOSTNONCE = 0xd93e69e2bbfa5735ULL |
static const uint64_t | RANDOMIZER_ID_ADDRCACHE = 0x1cf2e4ddd306dda9ULL |
bool | fDiscover = true |
bool | fListen = true |
RecursiveMutex | cs_mapLocalHost |
std::string | strSubVersion |
Subversion as sent to the P2P network in version messages. More... | |
static CNetCleanup | instance_of_cnetcleanup |
#define X | ( | name | ) | stats.name = name |
enum BindFlags |
Used to pass flags to the Bind() function.
Enumerator | |
---|---|
BF_NONE | |
BF_EXPLICIT | |
BF_REPORT_ERROR | |
BF_DONT_ADVERTISE | Do not call AddLocal() for our special addresses, e.g., for incoming Tor connections, to prevent gossiping them over the network. |
bool AddLocal | ( | const CService & | addr, |
int | nScore | ||
) |
bool AddLocal | ( | const CNetAddr & | addr, |
int | nScore | ||
) |
void AdvertiseLocal | ( | CNode * | pnode | ) |
|
static |
|
static |
|
static |
|
static |
|
static |
std::string ConnectionTypeAsString | ( | ConnectionType | conn_type | ) |
void Discover | ( | ) |
|
static |
uint16_t GetListenPort | ( | ) |
CAddress GetLocalAddress | ( | const CNetAddr * | paddrPeer, |
ServiceFlags | nLocalServices | ||
) |
|
static |
std::map<CNetAddr, LocalServiceInfo> mapLocalHost GUARDED_BY | ( | cs_mapLocalHost | ) |
bool IsLocal | ( | const CService & | addr | ) |
bool IsPeerAddrLocalGood | ( | CNode * | pnode | ) |
bool IsReachable | ( | enum Network | net | ) |
bool IsReachable | ( | const CNetAddr & | addr | ) |
int64_t PoissonNextSend | ( | int64_t | now, |
int | average_interval_seconds | ||
) |
void RemoveLocal | ( | const CService & | addr | ) |
|
static |
|
static |
bool SeenLocal | ( | const CService & | addr | ) |
Optional<NodeId> SelectNodeToEvict | ( | std::vector< NodeEvictionCandidate > && | vEvictionCandidates | ) |
void SetReachable | ( | enum Network | net, |
bool | reachable | ||
) |
const char* const ANCHORS_DATABASE_FILENAME = "anchors.dat" |
RecursiveMutex cs_mapLocalHost |
|
static |
How long to delay before querying DNS seeds.
If we have more than THRESHOLD entries in addrman, then it's likely that we got those addresses from having previously connected to the P2P network, and that we'll be able to successfully reconnect to the P2P network via contacting one of them. So if that's the case, spend a little longer trying to connect to known peers before querying the DNS seeds.
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |