mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-05-14 22:00:44 +02:00
Added seednode prioritization message to help output
This commit is contained in:
parent
3120a4678a
commit
82f41d76f1
@ -546,7 +546,7 @@ void SetupServerArgs(ArgsManager& argsman)
|
|||||||
argsman.AddArg("-proxy=<ip:port>", "Connect through SOCKS5 proxy, set -noproxy to disable (default: disabled)", ArgsManager::ALLOW_ANY | ArgsManager::DISALLOW_ELISION, OptionsCategory::CONNECTION);
|
argsman.AddArg("-proxy=<ip:port>", "Connect through SOCKS5 proxy, set -noproxy to disable (default: disabled)", ArgsManager::ALLOW_ANY | ArgsManager::DISALLOW_ELISION, OptionsCategory::CONNECTION);
|
||||||
#endif
|
#endif
|
||||||
argsman.AddArg("-proxyrandomize", strprintf("Randomize credentials for every proxy connection. This enables Tor stream isolation (default: %u)", DEFAULT_PROXYRANDOMIZE), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
|
argsman.AddArg("-proxyrandomize", strprintf("Randomize credentials for every proxy connection. This enables Tor stream isolation (default: %u)", DEFAULT_PROXYRANDOMIZE), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
|
||||||
argsman.AddArg("-seednode=<ip>", "Connect to a node to retrieve peer addresses, and disconnect. This option can be specified multiple times to connect to multiple nodes.", ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
|
argsman.AddArg("-seednode=<ip>", "Connect to a node to retrieve peer addresses, and disconnect. This option can be specified multiple times to connect to multiple nodes. During startup, seednodes will be tried before dnsseeds.", ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
|
||||||
argsman.AddArg("-networkactive", "Enable all P2P network activity (default: 1). Can be changed by the setnetworkactive RPC command", ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
|
argsman.AddArg("-networkactive", "Enable all P2P network activity (default: 1). Can be changed by the setnetworkactive RPC command", ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
|
||||||
argsman.AddArg("-timeout=<n>", strprintf("Specify socket connection timeout in milliseconds. If an initial attempt to connect is unsuccessful after this amount of time, drop it (minimum: 1, default: %d)", DEFAULT_CONNECT_TIMEOUT), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
|
argsman.AddArg("-timeout=<n>", strprintf("Specify socket connection timeout in milliseconds. If an initial attempt to connect is unsuccessful after this amount of time, drop it (minimum: 1, default: %d)", DEFAULT_CONNECT_TIMEOUT), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
|
||||||
argsman.AddArg("-peertimeout=<n>", strprintf("Specify a p2p connection timeout delay in seconds. After connecting to a peer, wait this amount of time before considering disconnection based on inactivity (minimum: 1, default: %d)", DEFAULT_PEER_CONNECT_TIMEOUT), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CONNECTION);
|
argsman.AddArg("-peertimeout=<n>", strprintf("Specify a p2p connection timeout delay in seconds. After connecting to a peer, wait this amount of time before considering disconnection based on inactivity (minimum: 1, default: %d)", DEFAULT_PEER_CONNECT_TIMEOUT), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CONNECTION);
|
||||||
|
26
src/net.cpp
26
src/net.cpp
@ -2168,35 +2168,37 @@ void CConnman::WakeMessageHandler()
|
|||||||
|
|
||||||
void CConnman::ThreadDNSAddressSeed()
|
void CConnman::ThreadDNSAddressSeed()
|
||||||
{
|
{
|
||||||
FastRandomContext rng;
|
constexpr int TARGET_OUTBOUND_CONNECTIONS = 2;
|
||||||
std::vector<std::string> seeds = m_params.DNSSeeds();
|
|
||||||
Shuffle(seeds.begin(), seeds.end(), rng);
|
|
||||||
int seeds_right_now = 0; // Number of seeds left before testing if we have enough connections
|
|
||||||
int target_outbound_connections = 2;
|
|
||||||
int outbound_connection_count = 0;
|
int outbound_connection_count = 0;
|
||||||
|
|
||||||
auto start = NodeClock::now();
|
|
||||||
if (gArgs.IsArgSet("-seednode")) {
|
if (gArgs.IsArgSet("-seednode")) {
|
||||||
LogPrintf("-seednode enabled. Trying the provided seeds before defaulting to the dnsseeds.\n");
|
auto start = NodeClock::now();
|
||||||
|
constexpr std::chrono::seconds SEEDNODE_TIMEOUT = 30s;
|
||||||
|
LogPrintf("-seednode enabled. Trying the provided seeds for %d seconds before defaulting to the dnsseeds.\n", SEEDNODE_TIMEOUT.count());
|
||||||
while (!interruptNet) {
|
while (!interruptNet) {
|
||||||
if (!interruptNet.sleep_for(std::chrono::milliseconds(500)))
|
if (!interruptNet.sleep_for(std::chrono::milliseconds(500)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Abort if we have spent enough time without reaching our target.
|
// Abort if we have spent enough time without reaching our target.
|
||||||
// Giving seed nodes 30 seconds so this does not become a race against fixedseeds (which triggers after 1 min)
|
// Giving seed nodes 30 seconds so this does not become a race against fixedseeds (which triggers after 1 min)
|
||||||
if (NodeClock::now() > start + 30s) {
|
if (NodeClock::now() > start + SEEDNODE_TIMEOUT) {
|
||||||
LogPrintf("Couldn't connect to enough peers via seed nodes. Handing fetch logic to the DNS seeds.\n");
|
LogPrintf("Couldn't connect to enough peers via seed nodes. Handing fetch logic to the DNS seeds.\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
outbound_connection_count = GetFullOutboundConnCount();
|
outbound_connection_count = GetFullOutboundConnCount();
|
||||||
if (outbound_connection_count >= target_outbound_connections) {
|
if (outbound_connection_count >= TARGET_OUTBOUND_CONNECTIONS) {
|
||||||
LogPrintf("P2P peers available. Finished fetching data from seed nodes.\n");
|
LogPrintf("P2P peers available. Finished fetching data from seed nodes.\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FastRandomContext rng;
|
||||||
|
std::vector<std::string> seeds = m_params.DNSSeeds();
|
||||||
|
Shuffle(seeds.begin(), seeds.end(), rng);
|
||||||
|
int seeds_right_now = 0; // Number of seeds left before testing if we have enough connections
|
||||||
|
|
||||||
if (gArgs.GetBoolArg("-forcednsseed", DEFAULT_FORCEDNSSEED)) {
|
if (gArgs.GetBoolArg("-forcednsseed", DEFAULT_FORCEDNSSEED)) {
|
||||||
// When -forcednsseed is provided, query all.
|
// When -forcednsseed is provided, query all.
|
||||||
seeds_right_now = seeds.size();
|
seeds_right_now = seeds.size();
|
||||||
@ -2208,7 +2210,7 @@ void CConnman::ThreadDNSAddressSeed()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Proceed with dnsseeds if seednodes hasn't reached the target or if forcednsseed is set
|
// Proceed with dnsseeds if seednodes hasn't reached the target or if forcednsseed is set
|
||||||
if (outbound_connection_count < target_outbound_connections || seeds_right_now) {
|
if (outbound_connection_count < TARGET_OUTBOUND_CONNECTIONS || seeds_right_now) {
|
||||||
// goal: only query DNS seed if address need is acute
|
// goal: only query DNS seed if address need is acute
|
||||||
// * If we have a reasonable number of peers in addrman, spend
|
// * If we have a reasonable number of peers in addrman, spend
|
||||||
// some time trying them first. This improves user privacy by
|
// some time trying them first. This improves user privacy by
|
||||||
@ -2239,7 +2241,7 @@ void CConnman::ThreadDNSAddressSeed()
|
|||||||
if (!interruptNet.sleep_for(w)) return;
|
if (!interruptNet.sleep_for(w)) return;
|
||||||
to_wait -= w;
|
to_wait -= w;
|
||||||
|
|
||||||
if (GetFullOutboundConnCount() >= target_outbound_connections) {
|
if (GetFullOutboundConnCount() >= TARGET_OUTBOUND_CONNECTIONS) {
|
||||||
if (found > 0) {
|
if (found > 0) {
|
||||||
LogPrintf("%d addresses found from DNS seeds\n", found);
|
LogPrintf("%d addresses found from DNS seeds\n", found);
|
||||||
LogPrintf("P2P peers available. Finished DNS seeding.\n");
|
LogPrintf("P2P peers available. Finished DNS seeding.\n");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user