Skip to content

Conversation

@mzumsande
Copy link
Contributor

Two fixups for #26847:

Now that Size() performs internal consistency checks,
it will rightfully fail (and assert) when dealing with
a corrupted AddrMan. Therefore remove this check.
@DrahtBot
Copy link
Contributor

DrahtBot commented Feb 1, 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 MarcoFalke

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

@maflcko
Copy link
Member

maflcko commented Feb 1, 2023

lgtm ACK dc70c1e

@fanquake
Copy link
Member

fanquake commented Feb 1, 2023

Going to merge this now to avoid further spurious CI failures.

@fanquake fanquake merged commit 2d5acc9 into bitcoin:master Feb 1, 2023
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Feb 1, 2023
dc70c1e addrman: Use std::nullopt instead of {} (Martin Zumsande)
59cc66a test: Remove AddrMan unit test that fails consistency checks (Martin Zumsande)

Pull request description:

  Two fixups for bitcoin#26847:
  * Now that `AddrMan::Size()` performs internal consistency tests (it didn't before), we can't call it in the `load_addrman_corrupted` unit tests, where we deal with an artificially corrupted `AddrMan`. This would fail the test when using `-checkaddrman=1` (leading to spurious CI fails). Therefore remove the tests assertion, which is not particularly helpful anyway (in production we abort init when peers.dat is corrupted instead of querying AddrMan in its corrupted state).
   (See bitcoin#26847 (comment))
  * Use `std::nullopt` instead of `{}` for default args (suggested in bitcoin#26847 (comment))

ACKs for top commit:
  MarcoFalke:
    lgtm ACK dc70c1e

Tree-SHA512: dd8a988e23d71a66d3dd30560bb653c9ad17db6915abfa5f722818b0ab18921051ec9223bfbc75d967df8bcd204dfe473d680bf68e8a8e4e4998fbb91dc973c5
Copy link
Contributor

@LarryRuane LarryRuane left a comment

Choose a reason for hiding this comment

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

post-merge ACK

* @return Number of unique addresses that match specified options.
*/
size_t Size(std::optional<Network> net = {}, std::optional<bool> in_new = {}) const;
size_t Size(std::optional<Network> net = std::nullopt, std::optional<bool> in_new = std::nullopt) const;
Copy link
Contributor

Choose a reason for hiding this comment

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

This is more clear, but I'm wondering, since the default constructor for std::optional is nullopt (see case 1 here, this seems completely intuitive), would have been better to leave off these initializers?

Copy link
Contributor

Choose a reason for hiding this comment

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

That would mean all callers have to always pass the arguments, even if they are std::nullopt, would not be possible to call it like addrman.Size().

Copy link
Contributor

Choose a reason for hiding this comment

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

You're right, ignore my comment.

@mzumsande mzumsande deleted the 202302_addrman_testfix branch May 4, 2023 16:40
@bitcoin bitcoin locked and limited conversation to collaborators May 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants