Changeset View
Changeset View
Standalone View
Standalone View
src/net.h
Show All 18 Lines | |||||
#include <net_permissions.h> | #include <net_permissions.h> | ||||
#include <netaddress.h> | #include <netaddress.h> | ||||
#include <protocol.h> | #include <protocol.h> | ||||
#include <random.h> | #include <random.h> | ||||
#include <streams.h> | #include <streams.h> | ||||
#include <sync.h> | #include <sync.h> | ||||
#include <threadinterrupt.h> | #include <threadinterrupt.h> | ||||
#include <uint256.h> | #include <uint256.h> | ||||
#include <validation.h> // For cs_main | |||||
#include <atomic> | #include <atomic> | ||||
#include <condition_variable> | #include <condition_variable> | ||||
#include <cstdint> | #include <cstdint> | ||||
#include <deque> | #include <deque> | ||||
#include <memory> | #include <memory> | ||||
#include <thread> | #include <thread> | ||||
▲ Show 20 Lines • Show All 138 Lines • ▼ Show 20 Lines | struct Options { | ||||
std::vector<std::string> m_specified_outgoing; | std::vector<std::string> m_specified_outgoing; | ||||
std::vector<std::string> m_added_nodes; | std::vector<std::string> m_added_nodes; | ||||
std::vector<bool> m_asmap; | std::vector<bool> m_asmap; | ||||
}; | }; | ||||
void Init(const Options &connOptions) { | void Init(const Options &connOptions) { | ||||
nLocalServices = connOptions.nLocalServices; | nLocalServices = connOptions.nLocalServices; | ||||
nMaxConnections = connOptions.nMaxConnections; | nMaxConnections = connOptions.nMaxConnections; | ||||
m_max_outbound_full_relay = std::min( | |||||
connOptions.m_max_outbound_full_relay, connOptions.nMaxConnections); | |||||
m_max_outbound_block_relay = connOptions.m_max_outbound_block_relay; | |||||
m_use_addrman_outgoing = connOptions.m_use_addrman_outgoing; | m_use_addrman_outgoing = connOptions.m_use_addrman_outgoing; | ||||
nMaxAddnode = connOptions.nMaxAddnode; | nMaxAddnode = connOptions.nMaxAddnode; | ||||
nMaxFeeler = connOptions.nMaxFeeler; | nMaxFeeler = connOptions.nMaxFeeler; | ||||
m_max_outbound = | { | ||||
m_max_outbound_full_relay + m_max_outbound_block_relay + nMaxFeeler; | // Lock cs_main to prevent a potential race with the peer validation | ||||
// logic thread. | |||||
LOCK(::cs_main); | |||||
m_max_outbound_full_relay = | |||||
std::min(connOptions.m_max_outbound_full_relay, | |||||
connOptions.nMaxConnections); | |||||
m_max_outbound_block_relay = connOptions.m_max_outbound_block_relay; | |||||
m_max_outbound = m_max_outbound_full_relay + | |||||
m_max_outbound_block_relay + nMaxFeeler; | |||||
} | |||||
nBestHeight = connOptions.nBestHeight; | nBestHeight = connOptions.nBestHeight; | ||||
clientInterface = connOptions.uiInterface; | clientInterface = connOptions.uiInterface; | ||||
m_banman = connOptions.m_banman; | m_banman = connOptions.m_banman; | ||||
m_msgproc = connOptions.m_msgproc; | m_msgproc = connOptions.m_msgproc; | ||||
nSendBufferMaxSize = connOptions.nSendBufferMaxSize; | nSendBufferMaxSize = connOptions.nSendBufferMaxSize; | ||||
nReceiveFloodSize = connOptions.nReceiveFloodSize; | nReceiveFloodSize = connOptions.nReceiveFloodSize; | ||||
m_peer_connect_timeout = connOptions.m_peer_connect_timeout; | m_peer_connect_timeout = connOptions.m_peer_connect_timeout; | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 882 Lines • Show Last 20 Lines |