Skip to content

Commit

Permalink
Merge bitcoin#30885: scripted-diff: Modernize nLocalServices naming
Browse files Browse the repository at this point in the history
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 bitcoin#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
  • Loading branch information
achow101 committed Oct 9, 2024
2 parents 5837e34 + 33381ea commit e569eb8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
12 changes: 6 additions & 6 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,7 @@ namespace { // Variables internal to initialization process only

int nMaxConnections;
int available_fds;
ServiceFlags nLocalServices = ServiceFlags(NODE_NETWORK_LIMITED | NODE_WITNESS);
ServiceFlags g_local_services = ServiceFlags(NODE_NETWORK_LIMITED | NODE_WITNESS);
int64_t peer_connect_timeout;
std::set<BlockFilterType> g_enabled_filter_types;

Expand Down Expand Up @@ -929,7 +929,7 @@ bool AppInitParameterInteraction(const ArgsManager& args)

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

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

nLocalServices = ServiceFlags(nLocalServices | NODE_COMPACT_FILTERS);
g_local_services = ServiceFlags(g_local_services | NODE_COMPACT_FILTERS);
}

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

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

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

CConnman::Options connOptions;
connOptions.nLocalServices = nLocalServices;
connOptions.m_local_services = g_local_services;
connOptions.m_max_automatic_connections = nMaxConnections;
connOptions.uiInterface = &uiInterface;
connOptions.m_banman = node.banman.get();
Expand Down
4 changes: 2 additions & 2 deletions src/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2950,7 +2950,7 @@ void CConnman::OpenNetworkConnection(const CAddress& addrConnect, bool fCountFai
return;
pnode->grantOutbound = std::move(grant_outbound);

m_msgproc->InitializeNode(*pnode, nLocalServices);
m_msgproc->InitializeNode(*pnode, m_local_services);
{
LOCK(m_nodes_mutex);
m_nodes.push_back(pnode);
Expand Down Expand Up @@ -3711,7 +3711,7 @@ uint64_t CConnman::GetTotalBytesSent() const

ServiceFlags CConnman::GetLocalServices() const
{
return nLocalServices;
return m_local_services;
}

static std::unique_ptr<Transport> MakeTransport(NodeId id, bool use_v2transport, bool inbound) noexcept
Expand Down
10 changes: 5 additions & 5 deletions src/net.h
Original file line number Diff line number Diff line change
Expand Up @@ -1035,7 +1035,7 @@ class CConnman

struct Options
{
ServiceFlags nLocalServices = NODE_NONE;
ServiceFlags m_local_services = NODE_NONE;
int m_max_automatic_connections = 0;
CClientUIInterface* uiInterface = nullptr;
NetEventsInterface* m_msgproc = nullptr;
Expand Down Expand Up @@ -1065,7 +1065,7 @@ class CConnman
{
AssertLockNotHeld(m_total_bytes_sent_mutex);

nLocalServices = connOptions.nLocalServices;
m_local_services = connOptions.m_local_services;
m_max_automatic_connections = connOptions.m_max_automatic_connections;
m_max_outbound_full_relay = std::min(MAX_OUTBOUND_FULL_RELAY_CONNECTIONS, m_max_automatic_connections);
m_max_outbound_block_relay = std::min(MAX_BLOCK_RELAY_ONLY_CONNECTIONS, m_max_automatic_connections - m_max_outbound_full_relay);
Expand Down Expand Up @@ -1223,8 +1223,8 @@ class CConnman

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

uint64_t GetMaxOutboundTarget() const EXCLUSIVE_LOCKS_REQUIRED(!m_total_bytes_sent_mutex);
std::chrono::seconds GetMaxOutboundTimeframe() const;
Expand Down Expand Up @@ -1470,7 +1470,7 @@ class CConnman
*
* \sa Peer::our_services
*/
std::atomic<ServiceFlags> nLocalServices;
std::atomic<ServiceFlags> m_local_services;

std::unique_ptr<CSemaphore> semOutbound;
std::unique_ptr<CSemaphore> semAddnode;
Expand Down

0 comments on commit e569eb8

Please sign in to comment.