Changeset View
Changeset View
Standalone View
Standalone View
src/net.h
Show First 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | |||||
/** | /** | ||||
* Time after which to disconnect, after waiting for a ping response (or | * Time after which to disconnect, after waiting for a ping response (or | ||||
* inactivity). | * inactivity). | ||||
*/ | */ | ||||
static const int TIMEOUT_INTERVAL = 20 * 60; | static const int TIMEOUT_INTERVAL = 20 * 60; | ||||
/** Run the feeler connection loop once every 2 minutes or 120 seconds. **/ | /** Run the feeler connection loop once every 2 minutes or 120 seconds. **/ | ||||
static const int FEELER_INTERVAL = 120; | static const int FEELER_INTERVAL = 120; | ||||
/** The maximum number of new addresses to accumulate before announcing. */ | /** | ||||
static const unsigned int MAX_ADDR_TO_SEND = 1000; | * The maximum number of addresses from our addrman to return in response to | ||||
// TODO: remove ADDRMAN_GETADDR_MAX and let the caller specify this limit with | * a getaddr message. | ||||
// MAX_ADDR_TO_SEND. | */ | ||||
static_assert(MAX_ADDR_TO_SEND == ADDRMAN_GETADDR_MAX, | static constexpr size_t MAX_ADDR_TO_SEND = 1000; | ||||
"Max allowed ADDR message size should be equal to the max number " | |||||
"of records returned from AddrMan."); | |||||
/** Maximum length of the user agent string in `version` message */ | /** Maximum length of the user agent string in `version` message */ | ||||
static const unsigned int MAX_SUBVERSION_LENGTH = 256; | static const unsigned int MAX_SUBVERSION_LENGTH = 256; | ||||
/** | /** | ||||
* Maximum number of automatic outgoing nodes over which we'll relay everything | * Maximum number of automatic outgoing nodes over which we'll relay everything | ||||
* (blocks, tx, addrs, etc) | * (blocks, tx, addrs, etc) | ||||
*/ | */ | ||||
static const int MAX_OUTBOUND_FULL_RELAY_CONNECTIONS = 8; | static const int MAX_OUTBOUND_FULL_RELAY_CONNECTIONS = 8; | ||||
/** Maximum number of addnode outgoing nodes */ | /** Maximum number of addnode outgoing nodes */ | ||||
▲ Show 20 Lines • Show All 260 Lines • ▼ Show 20 Lines | void ForEachNodeThen(Callable &&pre, CallableAfter &&post) const { | ||||
post(); | post(); | ||||
}; | }; | ||||
// Addrman functions | // Addrman functions | ||||
void SetServices(const CService &addr, ServiceFlags nServices); | void SetServices(const CService &addr, ServiceFlags nServices); | ||||
void MarkAddressGood(const CAddress &addr); | void MarkAddressGood(const CAddress &addr); | ||||
void AddNewAddresses(const std::vector<CAddress> &vAddr, | void AddNewAddresses(const std::vector<CAddress> &vAddr, | ||||
const CAddress &addrFrom, int64_t nTimePenalty = 0); | const CAddress &addrFrom, int64_t nTimePenalty = 0); | ||||
std::vector<CAddress> GetAddresses(); | std::vector<CAddress> GetAddresses(size_t max_addresses, size_t max_pct); | ||||
/** | /** | ||||
* Cache is used to minimize topology leaks, so it should | * Cache is used to minimize topology leaks, so it should | ||||
* be used for all non-trusted calls, for example, p2p. | * be used for all non-trusted calls, for example, p2p. | ||||
* A non-malicious call (from RPC or a peer with addr permission) should | * A non-malicious call (from RPC or a peer with addr permission) should | ||||
* call the function without a parameter to avoid using the cache. | * call the function without a parameter to avoid using the cache. | ||||
*/ | */ | ||||
std::vector<CAddress> GetAddresses(Network requestor_network); | std::vector<CAddress> GetAddresses(Network requestor_network, | ||||
size_t max_addresses, size_t max_pct); | |||||
// This allows temporarily exceeding m_max_outbound_full_relay, with the | // This allows temporarily exceeding m_max_outbound_full_relay, with the | ||||
// goal of finding a peer that is better than all our current peers. | // goal of finding a peer that is better than all our current peers. | ||||
void SetTryNewOutboundPeer(bool flag); | void SetTryNewOutboundPeer(bool flag); | ||||
bool GetTryNewOutboundPeer(); | bool GetTryNewOutboundPeer(); | ||||
// Return the number of outbound peers we have in excess of our target (eg, | // Return the number of outbound peers we have in excess of our target (eg, | ||||
// if we previously called SetTryNewOutboundPeer(true), and have since set | // if we previously called SetTryNewOutboundPeer(true), and have since set | ||||
▲ Show 20 Lines • Show All 1,003 Lines • Show Last 20 Lines |