Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: consistently use ApplyArgsManOptions for PeerManager::Options #28148

Merged
merged 2 commits into from Jul 27, 2023

Conversation

stickies-v
Copy link
Contributor

@stickies-v stickies-v commented Jul 25, 2023

Consistently use ApplyArgsManOptions for PeerManager::Options, and initialize PeerManager::Options early to avoid reading "-blocksonly" twice. Suggested in #27499 (comment) and also requested in #27499 (comment).

No behaviour change, but the TestingSetup is now also able to access "-blocksonly".

Refactor to consistently use ApplyArgsManOptions to set all PeerManager::Options,
including ignore_incoming_txs.
Initialize PeerManager::Options early to avoid reading -blocksonly twice.
@DrahtBot
Copy link
Contributor

DrahtBot commented Jul 25, 2023

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK TheCharlatan, dergoegge, MarcoFalke, achow101

If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

Conflicts

No conflicts as of last run.

@stickies-v stickies-v changed the title Refactor: consistently use ApplyArgsManOptions for PeerManager::Options refactor: consistently use ApplyArgsManOptions for PeerManager::Options Jul 25, 2023
Copy link
Contributor

@TheCharlatan TheCharlatan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 8a31597

Copy link
Member

@dergoegge dergoegge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK 8a31597

Thanks for the follow-up!

@theuni
Copy link
Member

theuni commented Jul 25, 2023

I'm not sure that I love using a subsystem's opts as a cache for init vars. But the consistency reasoning makes sense, so ~0 on that.

const bool ignores_incoming_txs{args.GetBoolArg("-blocksonly", DEFAULT_BLOCKSONLY)};

PeerManager::Options peerman_opts{};
ApplyArgsManOptions(args, peerman_opts);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unrelated in 8a31597: I think peermanager options have nothing to do with addrmanager options, so this could be moved down, closer to where it is used.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, makes more sense. Will move down if I have to retouch.

@maflcko
Copy link
Member

maflcko commented Jul 26, 2023

lgtm ACK 8a31597

@stickies-v
Copy link
Contributor Author

I'm not sure that I love using a subsystem's opts as a cache for init vars.

I felt iffy about it too (as per my initial suggestion), it's not the most elegant. I do think using a single var is safer and more clear than having a separate ignores_incoming_txs var, but I'm happy to drop the second commit if that's what people prefer.

@maflcko
Copy link
Member

maflcko commented Jul 26, 2023

You could add back the const bool ignores_incoming_txs{peerman_opts.ignore_incoming_txs}; alias? But I don't see what is iffy about the code. Are you saying it would be cleaner for node.fee_estimator to be constructed after the peerman, and using the peerman property instead of the peerman options property?

@@ -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) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No strong opinion, but it would be perfectly fine to just do

Suggested change
if (!peerman_opts.ignore_incoming_txs) {
if (!args.GetBoolArg("-blocksonly", DEFAULT_BLOCKSONLY)) {

here and then keep the peerman opts were they are right now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that would be my approach if not the current one. But going to keep as is for now since everyone seems to be happy with the current approach.

@stickies-v
Copy link
Contributor Author

But I don't see what is iffy about the code.

Using a PeerManager::Options object to initialize fee estimation is what irks me a bit. I suppose using peerman instead of the options object would be a bit more elegant indeed, but not worth the code rearrangement atm.

Looks like everyone's happy with the approach as is, so am going to refrain from further changes for now.

@achow101
Copy link
Member

ACK 8a31597

@achow101 achow101 merged commit 272c4f3 into bitcoin:master Jul 27, 2023
15 checks passed
@stickies-v stickies-v deleted the 2023-07/blocksonly-peerman-opts branch July 27, 2023 15:38
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Aug 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants