mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-06-25 16:31:29 +02:00
Merge bitcoin/bitcoin#28148: refactor: consistently use ApplyArgsManOptions for PeerManager::Options
8a3159728ae84cb8093e2e9fa5d2c2b0a7d545da refactor: deduplicate ignores_incoming_txs (stickies-v)
5f41afcc46913dbd4b5f08e622c5f74cd1eb50a5 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 https://github.com/bitcoin/bitcoin/pull/27499#discussion_r1268400386 and also requested in https://github.com/bitcoin/bitcoin/pull/27499#discussion_r1273346189.
No behaviour change, but the [`TestingSetup`](e35fb7bc48/src/test/util/setup_common.cpp (L255-L256)
) is now also able to access `"-blocksonly"`.
ACKs for top commit:
MarcoFalke:
lgtm ACK 8a3159728ae84cb8093e2e9fa5d2c2b0a7d545da
achow101:
ACK 8a3159728ae84cb8093e2e9fa5d2c2b0a7d545da
TheCharlatan:
ACK 8a3159728ae84cb8093e2e9fa5d2c2b0a7d545da
dergoegge:
utACK 8a3159728ae84cb8093e2e9fa5d2c2b0a7d545da
Tree-SHA512: 6cb489d79ac2a87e8faedb76c96973ab3fc597426f274a90a3ffd0bc5fe3f2b25db9c7ec2e55a0c806c2bcbc0fdded6e228adb43d2cd81f14fd6552863847698
This commit is contained in:
commit
272c4f3f10
12
src/init.cpp
12
src/init.cpp
@ -1168,7 +1168,9 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
|
|||||||
|
|
||||||
fListen = args.GetBoolArg("-listen", DEFAULT_LISTEN);
|
fListen = args.GetBoolArg("-listen", DEFAULT_LISTEN);
|
||||||
fDiscover = args.GetBoolArg("-discover", true);
|
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);
|
assert(!node.fee_estimator);
|
||||||
// Don't initialize fee estimation with old data if we don't relay transactions,
|
// Don't initialize fee estimation with old data if we don't relay transactions,
|
||||||
// as they would never get updated.
|
// 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);
|
bool read_stale_estimates = args.GetBoolArg("-acceptstalefeeestimates", DEFAULT_ACCEPT_STALE_FEE_ESTIMATES);
|
||||||
if (read_stale_estimates && (chainparams.GetChainType() != ChainType::REGTEST)) {
|
if (read_stale_estimates && (chainparams.GetChainType() != ChainType::REGTEST)) {
|
||||||
return InitError(strprintf(_("acceptstalefeeestimates is not supported on %s chain."), chainparams.GetChainTypeString()));
|
return InitError(strprintf(_("acceptstalefeeestimates is not supported on %s chain."), chainparams.GetChainTypeString()));
|
||||||
@ -1539,12 +1541,6 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
|
|||||||
|
|
||||||
ChainstateManager& chainman = *Assert(node.chainman);
|
ChainstateManager& chainman = *Assert(node.chainman);
|
||||||
|
|
||||||
|
|
||||||
PeerManager::Options peerman_opts{
|
|
||||||
.ignore_incoming_txs = ignores_incoming_txs,
|
|
||||||
};
|
|
||||||
ApplyArgsManOptions(args, peerman_opts);
|
|
||||||
|
|
||||||
assert(!node.peerman);
|
assert(!node.peerman);
|
||||||
node.peerman = PeerManager::make(*node.connman, *node.addrman,
|
node.peerman = PeerManager::make(*node.connman, *node.addrman,
|
||||||
node.banman.get(), chainman,
|
node.banman.get(), chainman,
|
||||||
|
@ -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("-capturemessages")}) options.capture_messages = *value;
|
||||||
|
|
||||||
|
if (auto value{argsman.GetBoolArg("-blocksonly")}) options.ignore_incoming_txs = *value;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace node
|
} // namespace node
|
||||||
|
Loading…
x
Reference in New Issue
Block a user