Skip to content

Commit e569eb8

Browse files
committed
Merge bitcoin/bitcoin#30885: scripted-diff: Modernize nLocalServices naming
33381ea scripted-diff: Modernize nLocalServices to m_local_services (Fabian Jahr) Pull request description: The type of the `nLocalServices` variable was changed to `std::atomic<ServiceFlags>` in #30807 and I suggested the variable name to get updated with a scripted diff along with it. It wasn't included in the PR but I am still suggesting to do it as a follow-up since I had already prepared the commit. ACKs for top commit: sipa: utACK 33381ea achow101: ACK 33381ea furszy: utACK 33381ea jonatack: ACK 33381ea theStack: ACK 33381ea Tree-SHA512: 407ea9eac694f079aa5b5c1611b5874d7a0897ba6bc3aa0570be94afe1bf3a826657b6890b6597c03c063e95b9dc868f0bdfbfc41e77ec7e06f5b045bf065c71
2 parents 5837e34 + 33381ea commit e569eb8

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

src/init.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,7 @@ namespace { // Variables internal to initialization process only
814814

815815
int nMaxConnections;
816816
int available_fds;
817-
ServiceFlags nLocalServices = ServiceFlags(NODE_NETWORK_LIMITED | NODE_WITNESS);
817+
ServiceFlags g_local_services = ServiceFlags(NODE_NETWORK_LIMITED | NODE_WITNESS);
818818
int64_t peer_connect_timeout;
819819
std::set<BlockFilterType> g_enabled_filter_types;
820820

@@ -929,7 +929,7 @@ bool AppInitParameterInteraction(const ArgsManager& args)
929929

930930
// Signal NODE_P2P_V2 if BIP324 v2 transport is enabled.
931931
if (args.GetBoolArg("-v2transport", DEFAULT_V2_TRANSPORT)) {
932-
nLocalServices = ServiceFlags(nLocalServices | NODE_P2P_V2);
932+
g_local_services = ServiceFlags(g_local_services | NODE_P2P_V2);
933933
}
934934

935935
// Signal NODE_COMPACT_FILTERS if peerblockfilters and basic filters index are both enabled.
@@ -938,7 +938,7 @@ bool AppInitParameterInteraction(const ArgsManager& args)
938938
return InitError(_("Cannot set -peerblockfilters without -blockfilterindex."));
939939
}
940940

941-
nLocalServices = ServiceFlags(nLocalServices | NODE_COMPACT_FILTERS);
941+
g_local_services = ServiceFlags(g_local_services | NODE_COMPACT_FILTERS);
942942
}
943943

944944
if (args.GetIntArg("-prune", 0)) {
@@ -1023,7 +1023,7 @@ bool AppInitParameterInteraction(const ArgsManager& args)
10231023
SetMockTime(args.GetIntArg("-mocktime", 0)); // SetMockTime(0) is a no-op
10241024

10251025
if (args.GetBoolArg("-peerbloomfilters", DEFAULT_PEERBLOOMFILTERS))
1026-
nLocalServices = ServiceFlags(nLocalServices | NODE_BLOOM);
1026+
g_local_services = ServiceFlags(g_local_services | NODE_BLOOM);
10271027

10281028
if (args.IsArgSet("-test")) {
10291029
if (chainparams.GetChainType() != ChainType::REGTEST) {
@@ -1716,7 +1716,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
17161716
// Prior to setting NODE_NETWORK, check if we can provide historical blocks.
17171717
if (!WITH_LOCK(chainman.GetMutex(), return chainman.BackgroundSyncInProgress())) {
17181718
LogPrintf("Setting NODE_NETWORK on non-prune mode\n");
1719-
nLocalServices = ServiceFlags(nLocalServices | NODE_NETWORK);
1719+
g_local_services = ServiceFlags(g_local_services | NODE_NETWORK);
17201720
} else {
17211721
LogPrintf("Running node in NODE_NETWORK_LIMITED mode until snapshot background sync completes\n");
17221722
}
@@ -1835,7 +1835,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
18351835
StartMapPort(args.GetBoolArg("-upnp", DEFAULT_UPNP), args.GetBoolArg("-natpmp", DEFAULT_NATPMP));
18361836

18371837
CConnman::Options connOptions;
1838-
connOptions.nLocalServices = nLocalServices;
1838+
connOptions.m_local_services = g_local_services;
18391839
connOptions.m_max_automatic_connections = nMaxConnections;
18401840
connOptions.uiInterface = &uiInterface;
18411841
connOptions.m_banman = node.banman.get();

src/net.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -2950,7 +2950,7 @@ void CConnman::OpenNetworkConnection(const CAddress& addrConnect, bool fCountFai
29502950
return;
29512951
pnode->grantOutbound = std::move(grant_outbound);
29522952

2953-
m_msgproc->InitializeNode(*pnode, nLocalServices);
2953+
m_msgproc->InitializeNode(*pnode, m_local_services);
29542954
{
29552955
LOCK(m_nodes_mutex);
29562956
m_nodes.push_back(pnode);
@@ -3711,7 +3711,7 @@ uint64_t CConnman::GetTotalBytesSent() const
37113711

37123712
ServiceFlags CConnman::GetLocalServices() const
37133713
{
3714-
return nLocalServices;
3714+
return m_local_services;
37153715
}
37163716

37173717
static std::unique_ptr<Transport> MakeTransport(NodeId id, bool use_v2transport, bool inbound) noexcept

src/net.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -1035,7 +1035,7 @@ class CConnman
10351035

10361036
struct Options
10371037
{
1038-
ServiceFlags nLocalServices = NODE_NONE;
1038+
ServiceFlags m_local_services = NODE_NONE;
10391039
int m_max_automatic_connections = 0;
10401040
CClientUIInterface* uiInterface = nullptr;
10411041
NetEventsInterface* m_msgproc = nullptr;
@@ -1065,7 +1065,7 @@ class CConnman
10651065
{
10661066
AssertLockNotHeld(m_total_bytes_sent_mutex);
10671067

1068-
nLocalServices = connOptions.nLocalServices;
1068+
m_local_services = connOptions.m_local_services;
10691069
m_max_automatic_connections = connOptions.m_max_automatic_connections;
10701070
m_max_outbound_full_relay = std::min(MAX_OUTBOUND_FULL_RELAY_CONNECTIONS, m_max_automatic_connections);
10711071
m_max_outbound_block_relay = std::min(MAX_BLOCK_RELAY_ONLY_CONNECTIONS, m_max_automatic_connections - m_max_outbound_full_relay);
@@ -1223,8 +1223,8 @@ class CConnman
12231223

12241224
//! Updates the local services that this node advertises to other peers
12251225
//! during connection handshake.
1226-
void AddLocalServices(ServiceFlags services) { nLocalServices = ServiceFlags(nLocalServices | services); };
1227-
void RemoveLocalServices(ServiceFlags services) { nLocalServices = ServiceFlags(nLocalServices & ~services); }
1226+
void AddLocalServices(ServiceFlags services) { m_local_services = ServiceFlags(m_local_services | services); };
1227+
void RemoveLocalServices(ServiceFlags services) { m_local_services = ServiceFlags(m_local_services & ~services); }
12281228

12291229
uint64_t GetMaxOutboundTarget() const EXCLUSIVE_LOCKS_REQUIRED(!m_total_bytes_sent_mutex);
12301230
std::chrono::seconds GetMaxOutboundTimeframe() const;
@@ -1470,7 +1470,7 @@ class CConnman
14701470
*
14711471
* \sa Peer::our_services
14721472
*/
1473-
std::atomic<ServiceFlags> nLocalServices;
1473+
std::atomic<ServiceFlags> m_local_services;
14741474

14751475
std::unique_ptr<CSemaphore> semOutbound;
14761476
std::unique_ptr<CSemaphore> semAddnode;

0 commit comments

Comments
 (0)