From 86651d81971bf46381bd01f050190aab4350daf2 Mon Sep 17 00:00:00 2001 From: Matthew Zipkin Date: Tue, 4 Aug 2026 14:43:12 +0000 Subject: [PATCH] scripted-diff: Rename nUserBind, nBind, nMaxConnections to snake_case -BEGIN VERIFY SCRIPT- sed -i 's/\bnUserBind\b/num_user_p2p_bind/g' src/init.cpp sed -i 's/\bnBind\b/num_p2p_bind/g' src/init.cpp sed -i 's/\bnMaxConnections\b/num_p2p_max_connections/g' src/init.cpp sed -i 's/\buser_max_connection\b/user_p2p_max_connections/g' src/init.cpp -END VERIFY SCRIPT- --- src/init.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index c25e07bf65f..13fa5e621a9 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -895,7 +895,7 @@ void InitLogging(const ArgsManager& args) namespace { // Variables internal to initialization process only -int nMaxConnections; +int num_p2p_max_connections; int available_fds; ServiceFlags g_local_services = ServiceFlags(NODE_NETWORK_LIMITED | NODE_WITNESS); int64_t peer_connect_timeout; @@ -1051,8 +1051,8 @@ bool AppInitParameterInteraction(const ArgsManager& args) } // -bind and -whitebind can't be set when not listening - size_t nUserBind = args.GetArgs("-bind").size() + args.GetArgs("-whitebind").size(); - if (nUserBind != 0 && !args.GetBoolArg("-listen", DEFAULT_LISTEN)) { + size_t num_user_p2p_bind = args.GetArgs("-bind").size() + args.GetArgs("-whitebind").size(); + if (num_user_p2p_bind != 0 && !args.GetBoolArg("-listen", DEFAULT_LISTEN)) { return InitError(Untranslated("Cannot set -bind or -whitebind together with -listen=0")); } @@ -1065,20 +1065,20 @@ bool AppInitParameterInteraction(const ArgsManager& args) // plus all manual connections and all bound interfaces. Any remainder will be available for connection sockets // Number of bound interfaces (we have at least one) - int nBind = std::max(nUserBind, size_t(1)); + int num_p2p_bind = std::max(num_user_p2p_bind, size_t(1)); // Maximum number of connections with other nodes, this accounts for all types of outbounds and inbounds except for manual - int user_max_connection = args.GetIntArg("-maxconnections", DEFAULT_MAX_PEER_CONNECTIONS); - if (user_max_connection < 0) { + int user_p2p_max_connections = args.GetIntArg("-maxconnections", DEFAULT_MAX_PEER_CONNECTIONS); + if (user_p2p_max_connections < 0) { return InitError(Untranslated("-maxconnections must be greater or equal than zero")); } const size_t max_private{args.GetBoolArg("-privatebroadcast", DEFAULT_PRIVATE_BROADCAST) ? MAX_PRIVATE_BROADCAST_CONNECTIONS : 0}; // Reserve enough FDs to account for the bare minimum, plus any manual connections, plus the bound interfaces - int min_required_fds = MIN_CORE_FDS + MAX_ADDNODE_CONNECTIONS + nBind; + int min_required_fds = MIN_CORE_FDS + MAX_ADDNODE_CONNECTIONS + num_p2p_bind; // Try raising the FD limit to what we need (available_fds may be smaller than the requested amount if this fails) - available_fds = RaiseFileDescriptorLimit(user_max_connection + max_private + min_required_fds); + available_fds = RaiseFileDescriptorLimit(user_p2p_max_connections + max_private + min_required_fds); // If we are using select instead of poll, our actual limit may be even smaller #ifndef USE_POLL available_fds = std::min(FD_SETSIZE, available_fds); @@ -1087,10 +1087,10 @@ bool AppInitParameterInteraction(const ArgsManager& args) return InitError(strprintf(_("Not enough file descriptors available. %d available, %d required."), available_fds, min_required_fds)); // Trim requested connection counts, to fit into system limitations - nMaxConnections = std::min(available_fds - min_required_fds, user_max_connection); + num_p2p_max_connections = std::min(available_fds - min_required_fds, user_p2p_max_connections); - if (nMaxConnections < user_max_connection) - InitWarning(strprintf(_("Reducing -maxconnections from %d to %d, because of system limitations."), user_max_connection, nMaxConnections)); + if (num_p2p_max_connections < user_p2p_max_connections) + InitWarning(strprintf(_("Reducing -maxconnections from %d to %d, because of system limitations."), user_p2p_max_connections, num_p2p_max_connections)); // ********************************************************* Step 3: parameter-to-internal-flags if (auto result{init::SetLoggingCategories(args)}; !result) return InitError(util::ErrorString(result)); @@ -1470,7 +1470,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) return false; } - LogInfo("Using at most %i automatic connections (%i file descriptors available)", nMaxConnections, available_fds); + LogInfo("Using at most %i automatic connections (%i file descriptors available)", num_p2p_max_connections, available_fds); // Warn about relative -datadir path. if (args.IsArgSet("-datadir") && !args.GetPathArg("-datadir").is_absolute()) { @@ -2137,7 +2137,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) CConnman::Options connOptions; connOptions.m_local_services = g_local_services; - connOptions.m_max_automatic_connections = nMaxConnections; + connOptions.m_max_automatic_connections = num_p2p_max_connections; connOptions.m_full_relay_inbound_percent = std::clamp(args.GetIntArg("-inboundrelaypercent", DEFAULT_FULL_RELAY_INBOUND_PCT), 0, 100); connOptions.uiInterface = &uiInterface; connOptions.m_banman = node.banman.get();