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: Remove nMyStartingHeight from CNode/Connman #20649

Merged
merged 1 commit into from Jan 2, 2021

Conversation

maflcko
Copy link
Member

@maflcko maflcko commented Dec 14, 2020

CNode and CConnman keep track of the active chain height when CNodes have been created, but apart from serializing the int once (when sending a version message), it is unused. So it can simply be removed in favor of a single int in PeerMan that can do the same.

@jnewbery
Copy link
Contributor

Concept ACK. I have a branch that does almost exactly the same as this.

I don't think we even need to storem_best_height in PeerManager. We can just call ::ChainActive().Height() whenever we want to send a version message.

@maflcko
Copy link
Member Author

maflcko commented Dec 14, 2020

just call ::ChainActive().Height() whenever we want to send a version message.

I was thinking that it would be nice (in the future) if most message handling could be done without cs_main.

@jnewbery
Copy link
Contributor

I was thinking that it would be nice (in the future) if most message handling could be done without cs_main.

This would definitely be nice! At the moment, both places we send a version message require cs_main at some point, so we're quite far off at the moment.

I have a preference for not caching the block height in PeerManager since I think it makes isolating and testing behaviour more difficult, but either way, this is clearly a big improvement over the current code.

@DrahtBot
Copy link
Contributor

🕵️ @sipa has been requested to review this pull request as specified in the REVIEWERS file.

@DrahtBot
Copy link
Contributor

DrahtBot commented Dec 14, 2020

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

Conflicts

Reviewers, this pull request conflicts with the following ones:

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@jnewbery
Copy link
Contributor

Code review ACK fa7afc0

@maflcko
Copy link
Member Author

maflcko commented Dec 16, 2020

rebased

@jnewbery
Copy link
Contributor

code review ACK faf54d4

@naumenkogs
Copy link
Member

Concept ACK

@jnewbery
Copy link
Contributor

Code review ACK fa8a96a

Copy link
Contributor

@theStack theStack left a comment

Choose a reason for hiding this comment

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

Nice cleanup!
Code review ACK fa8a96a ☃️

@maflcko
Copy link
Member Author

maflcko commented Jan 2, 2021

Rebased due to trivial conflict in adjacent line

@jnewbery
Copy link
Contributor

jnewbery commented Jan 2, 2021

utACK faaa4f2

Copy link
Contributor

@theStack theStack left a comment

Choose a reason for hiding this comment

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

re-ACK faaa4f2
Checked that the changes since my previous cr ACK were only rebase-related via $ git range-diff fa8a96a9146...faaa4f2b6af, also compiled and ran the tests.

@maflcko maflcko merged commit 6f97172 into bitcoin:master Jan 2, 2021
@maflcko maflcko deleted the 2012-netNoMyHeight branch January 2, 2021 12:08
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Jan 2, 2021
Fabcien pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Jan 25, 2022
Summary:
```
CNode and CConnman keep track of the active chain height when CNodes have been created, but apart from serializing the int once (when sending a version message), it is unused. So it can simply be removed in favor of a single int in PeerMan that can do the same.
```

Backport of [[bitcoin/bitcoin#20649 | core#20649]].

Depends on D10884.

Ref T1696.

Test Plan:
  ninja all check-all
  ninja bitcoin-fuzzers

Reviewers: #bitcoin_abc, PiRK

Reviewed By: #bitcoin_abc, PiRK

Subscribers: PiRK

Maniphest Tasks: T1696

Differential Revision: https://reviews.bitcoinabc.org/D10885
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Aug 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants