-
Notifications
You must be signed in to change notification settings - Fork 38.7k
p2p, rpc: address relay fixups #22616
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
Conversation
|
Could use |
Sure, will have a look. Might be better as a separate refactoring patch? |
|
good catch on the RE:
good idea @MarcoFalke! FYI @jonatack I'm also going to take a look. having compiler catch this error seems like a good move because clearly I missed it 😛 |
|
@amitiuttarwar sgtm, go for it, happy to review! |
|
took a look, unfortunately I don't think having example of accessing fields of a std::nullopt... compiles fine =\ |
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, 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. |
|
yes...did jonatack@397c33c as a warmup, it builds and tests pass, and it seems to be a bit nicer as an interface but doesn't yet do what we're looking for, was thinking to then convert some of the |
|
Can you explain why this is something we don't want? Surely compilers are happy to compile UB, but that doesn't mean it won't be caught. Previously (returning a pair of Returning a
[1]: For example: #include <optional>
struct NewStruct {
int a;
int b;
};
std::optional<NewStruct> GetNodeStateStats() { return std::nullopt; }
int main() { return GetNodeStateStats()->a; } |
|
Note that on master it is impossible for valgrind to catch this because the memory is always filled: struct CNodeStateStats {
int nSyncHeight = -1;
int nCommonHeight = -1;
int m_starting_height = -1;
std::chrono::microseconds m_ping_wait;
std::vector<int> vHeightInFlight;
uint64_t m_addr_processed = 0;
uint64_t m_addr_rate_limited = 0;
bool m_addr_relay_enabled{false};
};If it wasn't filled, valgrind detecting it would depend on whether vs |
|
For my part, I wasn't sure if the direction started with in jonatack@397c33c was what you had in mind, versus for instance also or starting with making the struct member(s) std::optional themselves, or something else. It seems to be a separate refactoring from this small fix-up, but good to clarify the direction. |
|
I think one way to improve this would be to combine // ...
obj.pushKV("inbound", stats.fInbound);
obj.pushKV("bip152_hb_to", stats.m_bip152_highbandwidth_to);
obj.pushKV("bip152_hb_from", stats.m_bip152_highbandwidth_from);
if (stats->m_starting_height) obj.pushKV("startingheight", stats->m_starting_height.value());
if (stats->nSyncHeight) obj.pushKV("synced_headers", stats->nSyncHeight.value());
// etc ...That requires quite a bit of moving code around, since both net and net_processing would have to include the header that defines the combined stats struct. I made a start on that work, but it's very out of date: https://github.com/jnewbery/bitcoin/tree/2021-01-stats |
|
ACK 5e33f76 |
|
🐙 This pull request conflicts with the target branch and needs rebase. Want to unsubscribe from rebase notifications on this pull request? Just convert this pull request to a "draft". |
5e33f76 p2p, rpc: address relay fixups (Jon Atack) Pull request description: Following review of new changes merged today, move a use of `statestats` in getpeerinfo to within the section guarded by `if (fStateStats)`, e.g. `PeerManagerImpl::GetNodeStateStats` true, and pass an in-param by reference to const. ACKs for top commit: amitiuttarwar: ACK 5e33f76 jnewbery: ACK 5e33f76 Tree-SHA512: b42f33c615b14079e2c4e6060209de8707d71b351dd1e11e04a2a6fc12d15747d0c5d9b24850217080fd1ef92e63f96d6925c4badf280b781edd696c349be7d6
Following review of new changes merged today, move a use of
statestatsin getpeerinfo to within the section guarded byif (fStateStats), e.g.PeerManagerImpl::GetNodeStateStatstrue, and pass an in-param by reference to const.