From 5f41afcc46913dbd4b5f08e622c5f74cd1eb50a5 Mon Sep 17 00:00:00 2001 From: stickies-v Date: Tue, 25 Jul 2023 12:08:08 +0100 Subject: refactor: set ignore_incoming_txs in ApplyArgsManOptions Refactor to consistently use ApplyArgsManOptions to set all PeerManager::Options, including ignore_incoming_txs. --- src/init.cpp | 4 +--- src/node/peerman_args.cpp | 2 ++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index 997996ef12..438ac8ff24 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1540,9 +1540,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) ChainstateManager& chainman = *Assert(node.chainman); - PeerManager::Options peerman_opts{ - .ignore_incoming_txs = ignores_incoming_txs, - }; + PeerManager::Options peerman_opts{}; ApplyArgsManOptions(args, peerman_opts); assert(!node.peerman); diff --git a/src/node/peerman_args.cpp b/src/node/peerman_args.cpp index e5868ead12..e0dcf21c33 100644 --- a/src/node/peerman_args.cpp +++ b/src/node/peerman_args.cpp @@ -18,6 +18,8 @@ void ApplyArgsManOptions(const ArgsManager& argsman, PeerManager::Options& optio } if (auto value{argsman.GetBoolArg("-capturemessages")}) options.capture_messages = *value; + + if (auto value{argsman.GetBoolArg("-blocksonly")}) options.ignore_incoming_txs = *value; } } // namespace node -- cgit v1.2.3 From 8a3159728ae84cb8093e2e9fa5d2c2b0a7d545da Mon Sep 17 00:00:00 2001 From: stickies-v Date: Tue, 25 Jul 2023 13:07:06 +0100 Subject: refactor: deduplicate ignores_incoming_txs Initialize PeerManager::Options early to avoid reading -blocksonly twice. --- src/init.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index 438ac8ff24..c11f100139 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1168,7 +1168,9 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) fListen = args.GetBoolArg("-listen", DEFAULT_LISTEN); fDiscover = args.GetBoolArg("-discover", true); - const bool ignores_incoming_txs{args.GetBoolArg("-blocksonly", DEFAULT_BLOCKSONLY)}; + + PeerManager::Options peerman_opts{}; + ApplyArgsManOptions(args, peerman_opts); { @@ -1216,7 +1218,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) assert(!node.fee_estimator); // Don't initialize fee estimation with old data if we don't relay transactions, // as they would never get updated. - if (!ignores_incoming_txs) { + if (!peerman_opts.ignore_incoming_txs) { bool read_stale_estimates = args.GetBoolArg("-acceptstalefeeestimates", DEFAULT_ACCEPT_STALE_FEE_ESTIMATES); if (read_stale_estimates && (chainparams.GetChainType() != ChainType::REGTEST)) { return InitError(strprintf(_("acceptstalefeeestimates is not supported on %s chain."), chainparams.GetChainTypeString())); @@ -1539,10 +1541,6 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) ChainstateManager& chainman = *Assert(node.chainman); - - PeerManager::Options peerman_opts{}; - ApplyArgsManOptions(args, peerman_opts); - assert(!node.peerman); node.peerman = PeerManager::make(*node.connman, *node.addrman, node.banman.get(), chainman, -- cgit v1.2.3