Skip to content

Commit 272c4f3

Browse files
committed
Merge bitcoin/bitcoin#28148: refactor: consistently use ApplyArgsManOptions for PeerManager::Options
8a31597 refactor: deduplicate ignores_incoming_txs (stickies-v) 5f41afc refactor: set ignore_incoming_txs in ApplyArgsManOptions (stickies-v) Pull request description: Consistently use `ApplyArgsManOptions` for `PeerManager::Options`, and initialize `PeerManager::Options` early to avoid reading `"-blocksonly"` twice. Suggested in bitcoin/bitcoin#27499 (comment) and also requested in bitcoin/bitcoin#27499 (comment). No behaviour change, but the [`TestingSetup`](https://github.com/bitcoin/bitcoin/blob/e35fb7bc48d360585b80d0c7f89ac5087c1d405e/src/test/util/setup_common.cpp#L255-L256) is now also able to access `"-blocksonly"`. ACKs for top commit: MarcoFalke: lgtm ACK 8a31597 achow101: ACK 8a31597 TheCharlatan: ACK 8a31597 dergoegge: utACK 8a31597 Tree-SHA512: 6cb489d79ac2a87e8faedb76c96973ab3fc597426f274a90a3ffd0bc5fe3f2b25db9c7ec2e55a0c806c2bcbc0fdded6e228adb43d2cd81f14fd6552863847698
2 parents dfe2dc1 + 8a31597 commit 272c4f3

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

src/init.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,7 +1168,9 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
11681168

11691169
fListen = args.GetBoolArg("-listen", DEFAULT_LISTEN);
11701170
fDiscover = args.GetBoolArg("-discover", true);
1171-
const bool ignores_incoming_txs{args.GetBoolArg("-blocksonly", DEFAULT_BLOCKSONLY)};
1171+
1172+
PeerManager::Options peerman_opts{};
1173+
ApplyArgsManOptions(args, peerman_opts);
11721174

11731175
{
11741176

@@ -1216,7 +1218,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
12161218
assert(!node.fee_estimator);
12171219
// Don't initialize fee estimation with old data if we don't relay transactions,
12181220
// as they would never get updated.
1219-
if (!ignores_incoming_txs) {
1221+
if (!peerman_opts.ignore_incoming_txs) {
12201222
bool read_stale_estimates = args.GetBoolArg("-acceptstalefeeestimates", DEFAULT_ACCEPT_STALE_FEE_ESTIMATES);
12211223
if (read_stale_estimates && (chainparams.GetChainType() != ChainType::REGTEST)) {
12221224
return InitError(strprintf(_("acceptstalefeeestimates is not supported on %s chain."), chainparams.GetChainTypeString()));
@@ -1539,12 +1541,6 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
15391541

15401542
ChainstateManager& chainman = *Assert(node.chainman);
15411543

1542-
1543-
PeerManager::Options peerman_opts{
1544-
.ignore_incoming_txs = ignores_incoming_txs,
1545-
};
1546-
ApplyArgsManOptions(args, peerman_opts);
1547-
15481544
assert(!node.peerman);
15491545
node.peerman = PeerManager::make(*node.connman, *node.addrman,
15501546
node.banman.get(), chainman,

src/node/peerman_args.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ void ApplyArgsManOptions(const ArgsManager& argsman, PeerManager::Options& optio
1818
}
1919

2020
if (auto value{argsman.GetBoolArg("-capturemessages")}) options.capture_messages = *value;
21+
22+
if (auto value{argsman.GetBoolArg("-blocksonly")}) options.ignore_incoming_txs = *value;
2123
}
2224

2325
} // namespace node

0 commit comments

Comments
 (0)