Skip to content

Conversation

@amitiuttarwar
Copy link
Contributor

this PR addresses outstanding review comments from #27214

retain the values needed to prevent redundant node lookups
Capture potential performance slow down for `Select` by network & clarify
return values.
@DrahtBot
Copy link
Contributor

DrahtBot commented May 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 mzumsande, brunoerg, achow101

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

@DrahtBot DrahtBot changed the title addrman: select addresses by network follow-up addrman: select addresses by network follow-up May 25, 2023
@DrahtBot DrahtBot added the P2P label May 25, 2023
@amitiuttarwar amitiuttarwar force-pushed the 2023-04-sbn-followups branch from 0cd26f2 to 486257b Compare May 26, 2023 22:47
`Assume` is safer since the checks are non-fatal- errors in these functions
should provide feedback in debug builds, but do not need to deter further node
operations in production.
Add a counter to ensure that the error case is bounded rather than leading to a
CI timeout
@amitiuttarwar amitiuttarwar force-pushed the 2023-04-sbn-followups branch from 486257b to cd8ef5b Compare May 26, 2023 22:48
Copy link
Contributor

@mzumsande mzumsande left a comment

Choose a reason for hiding this comment

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

Code Review ACK cd8ef5b

assert(it != mapInfo.end());
const auto info{it->second};
if (info.GetNetwork() == *network) break;
if (Assume(it != mapInfo.end()) && it->second.GetNetwork() == *network) break;
Copy link
Contributor

@mzumsande mzumsande May 31, 2023

Choose a reason for hiding this comment

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

I guess if the Assume assumption breaks the worst thing that could happen is that the while loop may run indefinitely - but it might also pick another address if there is one. So this seems better than crashing with an assert.

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, not the best but I think the chances of repeatedly not hitting the Assume condition to be extremely low. alternatively, I could add a counter to prevent that worst case if it seems worth the additional complexity.

Copy link
Contributor

@brunoerg brunoerg left a comment

Choose a reason for hiding this comment

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

crACK cd8ef5b

@achow101
Copy link
Member

ACK cd8ef5b

Checked that the changes here resolve the remaining review comments on #27214

@achow101 achow101 merged commit 6744d84 into bitcoin:master Jun 30, 2023
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Jul 1, 2023
cd8ef5b test: ensure addrman test is finite (Amiti Uttarwar)
b9f1e86 addrman: change asserts to Assumes (Amiti Uttarwar)
7687707 doc: update `Select` function description (Amiti Uttarwar)
2b6bd12 refactor: de-duplicate lookups (Amiti Uttarwar)

Pull request description:

  this PR addresses outstanding review comments from bitcoin#27214

ACKs for top commit:
  achow101:
    ACK cd8ef5b
  mzumsande:
    Code Review ACK cd8ef5b
  brunoerg:
    crACK cd8ef5b

Tree-SHA512: 669f67904263e3f51c39b175eabf5fa1b1e7b6841e889656afec33d0bd93fb446de9403f0a91b186ddeaf29498c8938484a0547b1188256c4e7c90db6f30bb55
@bitcoin bitcoin locked and limited conversation to collaborators Jun 29, 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