-
Notifications
You must be signed in to change notification settings - Fork 37.7k
rpc: add network field to getnodeaddresses #21594
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 34d84f3
Straightforward change that adds a useful network
field and makes welcome improvements to the getnodeaddresses
code.
utACK 34d84f3 |
src/rpc/net.cpp
Outdated
obj.pushKV("time", (int)addr.nTime); | ||
obj.pushKV("services", (uint64_t)addr.nServices); | ||
obj.pushKV("time", static_cast<int>(addr.nTime)); | ||
obj.pushKV("services", static_cast<uint64_t>(addr.nServices)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
obj.pushKV("services", static_cast<uint64_t>(addr.nServices)); | |
obj.pushKV("services", uint64_t{addr.nServices}); |
nit: I keep forgetting if this works for service flags, but C++11 casts are preferred over static_casts ;)
(Obviously don't force push unless you have to for other reasons)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That does work.
I wonder why we don't print the same services output(s) as for getpeerinfo and getnetworkinfo?
34d84f3
to
79d3e8f
Compare
Thanks everyone. Dropped the named casts change and added a release note into the first commit. |
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept and Code-review ACK 79d3e8f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept ACK.
nit, could squash 79d3e8f in 1st.
79d3e8f
to
5c44678
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re-ACK 5c44678
[
{
"time": 1615790934,
"services": 1033,
"address": "49.207.195.108",
"port": 18333,
"network": "ipv4"
},
{
"time": 1617277601,
"services": 1037,
"address": "2409:4070:4e8e:f61a:69a1:5d52:dc9:6b4e",
"port": 18333,
"network": "ipv6"
}
]
Hah great idea, I had been thinking about doing this myself. Concept ACK. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code review ACK 5c44678.
Tested ACK 5c44678 {
"time": 1617800381,
"services": 1032,
"address": "X.X.X.X",
"port": 8333,
"network": "ipv4"
},
{
"time": 1617793195,
"services": 1037,
"address": "X:X:X:X:X:X:X:X",
"port": 8333,
"network": "ipv6"
},
{
"time": 1617724603,
"services": 1033,
"address": "X.b32.i2p",
"port": 8333,
"network": "i2p"
},
{
"time": 1615423976,
"services": 1033,
"address": "X.onion",
"port": 8333,
"network": "onion"
}, |
Github-Pull: bitcoin#21594 Rebased-From: 3bb6e7b
e9d28da [Doc] Document getnodeaddresses in release notes (Fuzzbawls) ebe2a46 test: improve getnodeaddresses coverage, test by network (Fuzzbawls) 91ac5c7 rpc: enable filtering getnodeaddresses by network (Fuzzbawls) badfc49 p2p: allow CConnman::GetAddresses() by network, add doxygen (Fuzzbawls) fa78233 p2p: allow CAddrMan::GetAddr() by network, add doxygen (Fuzzbawls) a4d2733 p2p: pull time call out of loop in CAddrMan::GetAddr_() (Fuzzbawls) d5c1250 p2p: enable CAddrMan::GetAddr_() by network, add doxygen (Fuzzbawls) 67e2c2f [RPC] add network field to getnodeaddresses (Fuzzbawls) b4832b2 [Net] Add addpeeraddress RPC method (Fuzzbawls) 1a31b67 [test] Test that getnodeaddresses() can return all known addresses (Fuzzbawls) e83fd0e [Addrman] Specify max addresses and pct when calling GetAddresses() (Fuzzbawls) 792655d [RPC] Add getnodeaddresses RPC command (chris-belcher) Pull request description: Implement a new RPC command (`getnodeaddresses`) that provides RPC access to the node's addrman. It may be useful for PIVX wallets to broadcast their transactions over tor for improved privacy without using the centralized DNS seeds. I've included upstream improvements to this feature here as well, and this RPC command was used to scrape the Tor v3 hardcoded seed nodes added in #2502 --------- Based on the following upstream PRs: * bitcoin#13152 * bitcoin#19658 * bitcoin#21594 * bitcoin#21843 ACKs for top commit: furszy: all good, tested ACK e9d28da. random-zebra: utACK e9d28da and merging... Tree-SHA512: 2e50108504ac8e172c2e31eb64813d6aae6b6819cf197eace2e4e15686906708b2f82262909faad00ce64af0f61945089a36b857064d3ce2398b3acb14e4ad7d
Summary: Add network field to rpc `getnodeaddresses`. Simplify/constify code. Improve help. This is a backport of [[bitcoin/bitcoin#21594 | core#21594]] Depends on D11125 Test Plan: `ninja all check-all` Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Differential Revision: https://reviews.bitcoinabc.org/D11126
This patch adds a network field to RPC
getnodeaddresses
, which is useful on its own, particularly with the addition of new networks like I2P and others in the future, and which I also found helpful for adding a new CLI command as a follow-up to this pull that callsgetnodeaddresses
and needs to know the network of each address.While here, also improve the
getnodeaddresses
code and help.Future idea: allow passing
getnodeaddresses
a network (or networks) as an argument to return only addresses in that network.