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; | ||||
/** Run the extra block-relay-only connection loop once every 5 minutes. **/ | |||||
static const int EXTRA_BLOCK_RELAY_ONLY_PEER_INTERVAL = 300; | |||||
/** | /** | ||||
* The maximum number of addresses from our addrman to return in response to | * The maximum number of addresses from our addrman to return in response to | ||||
* a getaddr message. | * a getaddr message. | ||||
*/ | */ | ||||
static constexpr size_t MAX_ADDR_TO_SEND = 1000; | static constexpr size_t MAX_ADDR_TO_SEND = 1000; | ||||
/** 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; | ||||
/** | /** | ||||
▲ Show 20 Lines • Show All 1,038 Lines • ▼ Show 20 Lines | public: | ||||
std::vector<CAddress> GetAddresses(CNode &requestor, size_t max_addresses, | std::vector<CAddress> GetAddresses(CNode &requestor, size_t max_addresses, | ||||
size_t max_pct); | 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(); | ||||
void StartExtraBlockRelayPeers() { | |||||
LogPrint(BCLog::NET, "net: enabling extra block-relay-only peers\n"); | |||||
m_start_extra_block_relay_peers = true; | |||||
} | |||||
// 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 | ||||
// to false, we may have extra peers that we wish to disconnect). This may | // to false, we may have extra peers that we wish to disconnect). This may | ||||
// return a value less than (num_outbound_connections - num_outbound_slots) | // return a value less than (num_outbound_connections - num_outbound_slots) | ||||
// in cases where some outbound connections are not yet fully connected, or | // in cases where some outbound connections are not yet fully connected, or | ||||
// not yet fully disconnected. | // not yet fully disconnected. | ||||
int GetExtraOutboundCount(); | int GetExtraFullOutboundCount(); | ||||
// Count the number of block-relay-only peers we have over our limit. | |||||
int GetExtraBlockRelayCount(); | |||||
bool AddNode(const std::string &node); | bool AddNode(const std::string &node); | ||||
bool RemoveAddedNode(const std::string &node); | bool RemoveAddedNode(const std::string &node); | ||||
std::vector<AddedNodeInfo> GetAddedNodeInfo(); | std::vector<AddedNodeInfo> GetAddedNodeInfo(); | ||||
/** | /** | ||||
* Attempts to open a connection. Currently only used from tests. | * Attempts to open a connection. Currently only used from tests. | ||||
* | * | ||||
▲ Show 20 Lines • Show All 273 Lines • ▼ Show 20 Lines | private: | ||||
std::thread threadMessageHandler; | std::thread threadMessageHandler; | ||||
/** | /** | ||||
* flag for deciding to connect to an extra outbound peer, in excess of | * flag for deciding to connect to an extra outbound peer, in excess of | ||||
* m_max_outbound_full_relay. This takes the place of a feeler connection. | * m_max_outbound_full_relay. This takes the place of a feeler connection. | ||||
*/ | */ | ||||
std::atomic_bool m_try_another_outbound_peer; | std::atomic_bool m_try_another_outbound_peer; | ||||
/** | |||||
* flag for initiating extra block-relay-only peer connections. | |||||
* this should only be enabled after initial chain sync has occurred, | |||||
* as these connections are intended to be short-lived and low-bandwidth. | |||||
*/ | |||||
std::atomic_bool m_start_extra_block_relay_peers{false}; | |||||
std::atomic<int64_t> m_next_send_inv_to_incoming{0}; | std::atomic<int64_t> m_next_send_inv_to_incoming{0}; | ||||
/** | /** | ||||
* A vector of -bind=<address>:<port>=onion arguments each of which is | * A vector of -bind=<address>:<port>=onion arguments each of which is | ||||
* an address and port that are designated for incoming Tor connections. | * an address and port that are designated for incoming Tor connections. | ||||
*/ | */ | ||||
std::vector<CService> m_onion_binds; | std::vector<CService> m_onion_binds; | ||||
▲ Show 20 Lines • Show All 41 Lines • Show Last 20 Lines |