Skip to content

Commit fa5c224

Browse files
author
MacroFake
committed
Merge bitcoin/bitcoin#25887: init: avoid unsetting service bits from nLocalServices
1b5bec7 init: avoid unsetting service bits from `nLocalServices` (Sebastian Falbesoner) Pull request description: This PR is a late follow-up to the [review club session about the PR "Default to NODE_WITNESS in nLocalServices" ](https://bitcoincore.reviews/21090#l-90) (#21090): ``` 17:32 <lightlike> hmm, if we are in pruned mode, we first set NODE_NETWORK and then unset it later in init.cpp. that seems a bit strange. ... 17:33 <jnewbery> lightlike: ah yes, you're right. That does seem a bit messy. ``` Rather than setting the service bit `NODE_NETWORK` first and then unset it (if in `fPruneMode`), start with the bare minimum flags that we always serve and only add `NODE_NETWORK` if we are running as a non-pruned node. This seems to be a more logical approach than currently on master. ACKs for top commit: naumenkogs: ACK 1b5bec7 stickies-v: ACK 1b5bec7 LarryRuane: ACK 1b5bec7 Tree-SHA512: 2e82d66c4298ffacff41d9e0458b74b83bc156a1fa49e3f3471e942878e5dd2b253b5597ee5ec1d9c8726b432751d05e40f0c580f3976a9e00a7d1f417921ab0
2 parents ccea0e1 + 1b5bec7 commit fa5c224

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/init.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,7 @@ namespace { // Variables internal to initialization process only
742742
int nMaxConnections;
743743
int nUserMaxConnections;
744744
int nFD;
745-
ServiceFlags nLocalServices = ServiceFlags(NODE_NETWORK | NODE_NETWORK_LIMITED | NODE_WITNESS);
745+
ServiceFlags nLocalServices = ServiceFlags(NODE_NETWORK_LIMITED | NODE_WITNESS);
746746
int64_t peer_connect_timeout;
747747
std::set<BlockFilterType> g_enabled_filter_types;
748748

@@ -1519,18 +1519,19 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
15191519

15201520
// ********************************************************* Step 10: data directory maintenance
15211521

1522-
// if pruning, unset the service bit and perform the initial blockstore prune
1522+
// if pruning, perform the initial blockstore prune
15231523
// after any wallet rescanning has taken place.
15241524
if (fPruneMode) {
1525-
LogPrintf("Unsetting NODE_NETWORK on prune mode\n");
1526-
nLocalServices = ServiceFlags(nLocalServices & ~NODE_NETWORK);
15271525
if (!fReindex) {
15281526
LOCK(cs_main);
15291527
for (CChainState* chainstate : chainman.GetAll()) {
15301528
uiInterface.InitMessage(_("Pruning blockstore…").translated);
15311529
chainstate->PruneAndFlush();
15321530
}
15331531
}
1532+
} else {
1533+
LogPrintf("Setting NODE_NETWORK on non-prune mode\n");
1534+
nLocalServices = ServiceFlags(nLocalServices | NODE_NETWORK);
15341535
}
15351536

15361537
// ********************************************************* Step 11: import blocks

0 commit comments

Comments
 (0)