v31.1-roots.1 · Commit 5: [PATCH 05/17] feat(net): preserve Roots peer controls and health view on v31
src/init.cpp
Before: src/init.cpp · After: src/init.cpp
File metadata
index c686f4ffbbd327ab8a53ad73e4b6f4a653f8c50b..d49ceb56cf02bbc8cd8829ad51d5d864efee89fb 100644
Download original patch · Release notes
Diff rows 1–64 of 64. Line numbers refer to the original before/after files.
+ Added− RemovedUnmarked lines are context.
Scroll the code area horizontally to read long lines. Before is on the left; after is on the right. Unified view fits narrow screens more easily.
src/init.cpp
CHANGED
|
@@ -498,6 +498,7 @@ void SetupServerArgs(ArgsManager& argsman, bool can_listen_ipc)
|
|
| 498 |
argsman.AddArg("-blocknotify=<cmd>", "Execute command when the best block changes (%s in cmd is replaced by block hash)", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
|
| 499 |
#endif
|
| 500 |
argsman.AddArg("-blockreconstructionextratxn=<n>", strprintf("Extra transactions to keep in memory for compact block reconstructions (default: %u)", DEFAULT_BLOCK_RECONSTRUCTION_EXTRA_TXN), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
|
|
|
|
| 501 |
argsman.AddArg("-blocksonly", strprintf("Whether to reject transactions from network peers. Disables automatic broadcast and rebroadcast of transactions, unless the source peer has the 'forcerelay' permission. RPC transactions are not affected. (default: %u)", DEFAULT_BLOCKSONLY), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
|
| 502 |
argsman.AddArg("-coinstatsindex", strprintf("Maintain coinstats index used by the gettxoutsetinfo RPC (default: %u)", DEFAULT_COINSTATSINDEX), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
|
| 503 |
argsman.AddArg("-conf=<file>", strprintf("Specify path to read-only configuration file. Relative paths will be prefixed by datadir location (only useable from command line, not configuration file) (default: %s)", BITCOIN_CONF_FILENAME), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
|
|
@@ -570,6 +571,8 @@ void SetupServerArgs(ArgsManager& argsman, bool can_listen_ipc)
|
|
| 570 |
argsman.AddArg("-onlynet=<net>", "Make automatic outbound connections only to network <net> (" + Join(GetNetworkNames(), ", ") + "). Inbound and manual connections are not affected by this option. It can be specified multiple times to allow multiple networks.", ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
|
| 571 |
argsman.AddArg("-v2transport", strprintf("Support v2 transport (default: %u)", DEFAULT_V2_TRANSPORT), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
|
| 572 |
argsman.AddArg("-peerbloomfilters", strprintf("Support filtering of blocks and transaction with bloom filters (default: %u)", DEFAULT_PEERBLOOMFILTERS), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
|
|
|
|
|
|
|
| 573 |
argsman.AddArg("-peerblockfilters", strprintf("Serve compact block filters to peers per BIP 157 (default: %u)", DEFAULT_PEERBLOCKFILTERS), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
|
| 574 |
argsman.AddArg("-txreconciliation", strprintf("Enable transaction reconciliations per BIP 330 (default: %d)", DEFAULT_TXRECONCILIATION_ENABLE), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CONNECTION);
|
| 575 |
argsman.AddArg("-port=<port>", strprintf("Listen for connections on <port> (default: %u, testnet3: %u, testnet4: %u, signet: %u, regtest: %u). Not relevant for I2P (see doc/i2p.md). If set to a value x, the default onion listening port will be set to x+1.", defaultChainParams->GetDefaultPort(), testnetChainParams->GetDefaultPort(), testnet4ChainParams->GetDefaultPort(), signetChainParams->GetDefaultPort(), regtestChainParams->GetDefaultPort()), ArgsManager::ALLOW_ANY | ArgsManager::NETWORK_ONLY, OptionsCategory::CONNECTION);
|
|
@@ -2163,6 +2166,8 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
|
|
| 2163 |
connOptions.whitelist_forcerelay = args.GetBoolArg("-whitelistforcerelay", DEFAULT_WHITELISTFORCERELAY);
|
| 2164 |
connOptions.whitelist_relay = args.GetBoolArg("-whitelistrelay", DEFAULT_WHITELISTRELAY);
|
| 2165 |
connOptions.m_capture_messages = args.GetBoolArg("-capturemessages", false);
|
|
|
|
|
|
|
| 2166 |
|
| 2167 |
// Port to bind to if `-bind=addr` is provided without a `:port` suffix.
|
| 2168 |
const uint16_t default_bind_port =
|
|
@@ -2204,10 +2209,12 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
|
|
| 2204 |
return InitError(ResolveErrMsg("bind", bind_arg));
|
| 2205 |
}
|
| 2206 |
|
|
|
|
| 2207 |
for (const std::string& strBind : args.GetArgs("-whitebind")) {
|
| 2208 |
NetWhitebindPermissions whitebind;
|
| 2209 |
bilingual_str error;
|
| 2210 |
if (!NetWhitebindPermissions::TryParse(strBind, whitebind, error)) return InitError(error);
|
|
|
|
| 2211 |
connOptions.vWhiteBinds.push_back(whitebind);
|
| 2212 |
}
|
| 2213 |
|
|
@@ -2249,11 +2256,17 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
|
|
| 2249 |
Discover();
|
| 2250 |
}
|
| 2251 |
|
| 2252 |
-
for (const auto& net : args.GetArgs("-whitelist")) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2253 |
NetWhitelistPermissions subnet;
|
| 2254 |
ConnectionDirection connection_direction;
|
| 2255 |
bilingual_str error;
|
| 2256 |
if (!NetWhitelistPermissions::TryParse(net, subnet, connection_direction, error)) return InitError(error);
|
|
|
|
| 2257 |
if (connection_direction & ConnectionDirection::In) {
|
| 2258 |
connOptions.vWhitelistedRangeIncoming.push_back(subnet);
|
| 2259 |
}
|
|
@@ -2262,6 +2275,11 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
|
|
| 2262 |
}
|
| 2263 |
}
|
| 2264 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2265 |
connOptions.vSeedNodes = args.GetArgs("-seednode");
|
| 2266 |
|
| 2267 |
const auto connect = args.GetArgs("-connect");
|
|
|
|
| 498 |
argsman.AddArg("-blocknotify=<cmd>", "Execute command when the best block changes (%s in cmd is replaced by block hash)", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
|
| 499 |
#endif
|
| 500 |
argsman.AddArg("-blockreconstructionextratxn=<n>", strprintf("Extra transactions to keep in memory for compact block reconstructions (default: %u)", DEFAULT_BLOCK_RECONSTRUCTION_EXTRA_TXN), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
|
| 501 |
+
argsman.AddArg("-blockreconstructionextratxnsize=<n>", strprintf("Upper limit of memory usage (in decimal megabytes) for compact block extra transactions (default: %u)", DEFAULT_BLOCK_RECONSTRUCTION_EXTRA_TXN_SIZE / 1000000), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
|
| 502 |
argsman.AddArg("-blocksonly", strprintf("Whether to reject transactions from network peers. Disables automatic broadcast and rebroadcast of transactions, unless the source peer has the 'forcerelay' permission. RPC transactions are not affected. (default: %u)", DEFAULT_BLOCKSONLY), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
|
| 503 |
argsman.AddArg("-coinstatsindex", strprintf("Maintain coinstats index used by the gettxoutsetinfo RPC (default: %u)", DEFAULT_COINSTATSINDEX), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
|
| 504 |
argsman.AddArg("-conf=<file>", strprintf("Specify path to read-only configuration file. Relative paths will be prefixed by datadir location (only useable from command line, not configuration file) (default: %s)", BITCOIN_CONF_FILENAME), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
|
|
|
|
| 571 |
argsman.AddArg("-onlynet=<net>", "Make automatic outbound connections only to network <net> (" + Join(GetNetworkNames(), ", ") + "). Inbound and manual connections are not affected by this option. It can be specified multiple times to allow multiple networks.", ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
|
| 572 |
argsman.AddArg("-v2transport", strprintf("Support v2 transport (default: %u)", DEFAULT_V2_TRANSPORT), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
|
| 573 |
argsman.AddArg("-peerbloomfilters", strprintf("Support filtering of blocks and transaction with bloom filters (default: %u)", DEFAULT_PEERBLOOMFILTERS), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
|
| 574 |
+
argsman.AddArg("-v2onlyclearnet", "Disable outbound v1 connections and v1 fallback on IPv4/IPv6 (default: 0)", ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
|
| 575 |
+
argsman.AddArg("-feefilter", strprintf("Tell peers to filter transaction announcements by the mempool minimum fee (default: %u)", DEFAULT_FEEFILTER), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CONNECTION);
|
| 576 |
argsman.AddArg("-peerblockfilters", strprintf("Serve compact block filters to peers per BIP 157 (default: %u)", DEFAULT_PEERBLOCKFILTERS), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
|
| 577 |
argsman.AddArg("-txreconciliation", strprintf("Enable transaction reconciliations per BIP 330 (default: %d)", DEFAULT_TXRECONCILIATION_ENABLE), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CONNECTION);
|
| 578 |
argsman.AddArg("-port=<port>", strprintf("Listen for connections on <port> (default: %u, testnet3: %u, testnet4: %u, signet: %u, regtest: %u). Not relevant for I2P (see doc/i2p.md). If set to a value x, the default onion listening port will be set to x+1.", defaultChainParams->GetDefaultPort(), testnetChainParams->GetDefaultPort(), testnet4ChainParams->GetDefaultPort(), signetChainParams->GetDefaultPort(), regtestChainParams->GetDefaultPort()), ArgsManager::ALLOW_ANY | ArgsManager::NETWORK_ONLY, OptionsCategory::CONNECTION);
|
|
|
|
| 2166 |
connOptions.whitelist_forcerelay = args.GetBoolArg("-whitelistforcerelay", DEFAULT_WHITELISTFORCERELAY);
|
| 2167 |
connOptions.whitelist_relay = args.GetBoolArg("-whitelistrelay", DEFAULT_WHITELISTRELAY);
|
| 2168 |
connOptions.m_capture_messages = args.GetBoolArg("-capturemessages", false);
|
| 2169 |
+
connOptions.disable_v1conn_clearnet = args.GetBoolArg("-v2onlyclearnet", false);
|
| 2170 |
+
connOptions.listenonion = listenonion;
|
| 2171 |
|
| 2172 |
// Port to bind to if `-bind=addr` is provided without a `:port` suffix.
|
| 2173 |
const uint16_t default_bind_port =
|
|
|
|
| 2209 |
return InitError(ResolveErrMsg("bind", bind_arg));
|
| 2210 |
}
|
| 2211 |
|
| 2212 |
+
NetPermissionFlags all_permission_flags{NetPermissionFlags::None};
|
| 2213 |
for (const std::string& strBind : args.GetArgs("-whitebind")) {
|
| 2214 |
NetWhitebindPermissions whitebind;
|
| 2215 |
bilingual_str error;
|
| 2216 |
if (!NetWhitebindPermissions::TryParse(strBind, whitebind, error)) return InitError(error);
|
| 2217 |
+
NetPermissions::AddFlag(all_permission_flags, whitebind.m_flags);
|
| 2218 |
connOptions.vWhiteBinds.push_back(whitebind);
|
| 2219 |
}
|
| 2220 |
|
|
|
|
| 2256 |
Discover();
|
| 2257 |
}
|
| 2258 |
|
| 2259 |
+
std::vector<std::string> whitelist_opts{args.GetArgs("-whitelist")};
|
| 2260 |
+
if ((g_local_services & NODE_BLOOM) == NODE_NONE && args.GetBoolArg("-peerbloomfilters", true)) {
|
| 2261 |
+
whitelist_opts.emplace_back("in,out,bloomfilter@127.0.0.0/8");
|
| 2262 |
+
whitelist_opts.emplace_back("in,out,bloomfilter@[::1]/128");
|
| 2263 |
+
}
|
| 2264 |
+
for (const auto& net : whitelist_opts) {
|
| 2265 |
NetWhitelistPermissions subnet;
|
| 2266 |
ConnectionDirection connection_direction;
|
| 2267 |
bilingual_str error;
|
| 2268 |
if (!NetWhitelistPermissions::TryParse(net, subnet, connection_direction, error)) return InitError(error);
|
| 2269 |
+
NetPermissions::AddFlag(all_permission_flags, subnet.m_flags);
|
| 2270 |
if (connection_direction & ConnectionDirection::In) {
|
| 2271 |
connOptions.vWhitelistedRangeIncoming.push_back(subnet);
|
| 2272 |
}
|
|
|
|
| 2275 |
}
|
| 2276 |
}
|
| 2277 |
|
| 2278 |
+
if (NetPermissions::HasFlag(all_permission_flags, NetPermissionFlags::BlockFilters_Explicit) &&
|
| 2279 |
+
!g_enabled_filter_types.contains(BlockFilterType::BASIC)) {
|
| 2280 |
+
return InitError(_("Cannot grant blockfilters permission without -blockfilterindex."));
|
| 2281 |
+
}
|
| 2282 |
+
|
| 2283 |
connOptions.vSeedNodes = args.GetArgs("-seednode");
|
| 2284 |
|
| 2285 |
const auto connect = args.GetArgs("-connect");
|