net, rpc: return NET_UNROUTABLE as not_publicly_routable, automate helps#20965
net, rpc: return NET_UNROUTABLE as not_publicly_routable, automate helps#20965maflcko merged 4 commits intobitcoin:masterfrom
Conversation
2c25e6d to
d9ca419
Compare
theStack
left a comment
There was a problem hiding this comment.
ACK d9ca41964dae2bc58ed8f9639847951beb0f3453
d9ca419 to
181fe06
Compare
|
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. |
181fe06 to
b0ed5b1
Compare
b0ed5b1 to
355ca86
Compare
|
Updated per review feedback by @MarcoFalke and @theStack and added an optional commit to use named casts (can be dropped if preferred). |
355ca86 to
4c97ff2
Compare
theStack
left a comment
There was a problem hiding this comment.
light re-ACK 4c97ff24eef77bde3c27258f93e8d216caac9cc8 🦉
Reviewed the second commit via --color-moved=dimmed-zebra to verify that the changes involving GetNetworksInfo were move-only (apart from taking advantage of C++11 initializer list at one place) .
Changes LGTM, also replacing C-style casts with named casts is a good idea to enable compile time checks. My reason for only "light"-ACKing: I'm not 100% sure how dynamic the generation of RPC help texts is allowed to be, other uses of Join(...) in RPC help texts seem only to use constants:
$ git grep RPC.*Join
src/rpc/net.cpp: {RPCResult::Type::STR, "network", "Network (" + Join(GetNetworkNames(), ", ") + ")"},
src/rpc/net.cpp: {RPCResult::Type::STR, "permission_type", Join(NET_PERMISSIONS_DOC, ",\n") + ".\n"},
src/rpc/net.cpp: {RPCResult::Type::STR, "connection_type", "Type of connection: \n" + Join(CONNECTION_TYPE_DOC, ",\n") + ".\n"
src/rpc/net.cpp: {RPCResult::Type::STR, "name", "network (" + Join(GetNetworkNames(), ", ") + ")"},
|
@theStack thanks for having a look--I asked myself the same question and decided to start with proposing dynamic generation because returning the help doc isn't a perf hotspot and, unlike the two existing cases, this one can be generated automatically (the functional tests enforce a sanity check on any upstream updates). |
What is an example for a compile time check that is enabled when using those for numeric types? I am only aware of compile time checks that are enabled for pointers. Static casts for numeric values are just overly verbose for no reason and I'd prefer not to change existing code. |
If the destination type is numeric, the named cast asserts at compile time that also the source type is numeric, while a c-style cast doesn't in all cases: Also note that modern C++ coding guidelines discourage the use of C casts: That said, I'm happy to re-ACK this PR also without the third commit. |
maflcko
left a comment
There was a problem hiding this comment.
ok, fair enough on the static_cast, but changing existing code (especially one that is about to get removed) might not be worth it.
4c97ff2 to
23299de
Compare
|
Yup, dropped the last commit, it's not related to this change and can be done later when the relevant lines are touched. Thanks for reviewing! |
theStack
left a comment
There was a problem hiding this comment.
re-ACK 23299def6acda0c07d14274c605dbd4c9d23fe56 🍏
maflcko
left a comment
There was a problem hiding this comment.
left some feedback on 23299def6acda0c07d14274c605dbd4c9d23fe56 🔌
Show signature and timestamp
Signature:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
left some feedback on 23299def6acda0c07d14274c605dbd4c9d23fe56 🔌
-----BEGIN PGP SIGNATURE-----
iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
pUipnAv/YQrIj8eF8B2E2U0kCmbK1ftlsNowtsHgXUIHRB+1Ow8i3c7ZsjYnQp7Z
CfdGVWgiQ/4UkWIXlimM+8IBkQnkggupIQN4w4/3Gm7i9R3HlC4AMQV+Qov7Jhpn
qPRf2jbt9sUJCYt0tW7sH/TvwZTjJrOkM9wy6PseK8u06bTTWdVWRGjl/bZ7cCt5
RZ0sJ01AQ4y7dDCMgbKPx/t120RdzPwFT/blSLXi0/SIWZNtfX7oXQ+nlKEJ5bIa
jeg/z5P88QkfWsbMbSERycZW3WbFA13o7Um39P/tSdzBzOa8ykXA/fHdJo7g8oC/
SOQk8oqSJuDsL7jEkM78JrBt4AIiIOSuIXnafb0nvZ1ZA9tDoRrxsK7bNV2HZ9nr
fKuy++V7LJsMwRzn6jLeZARkHGDT8RNpTnpDYOiCC5dGfCgxJhwQ/hZ0mcVDrTZd
nGRo63Fe7O3zKnnenNZRHB5m+yfuq0rslIveDgNCeRdmusGrc+UnGAYcxQO++z5J
8PopnI7e
=tod6
-----END PGP SIGNATURE-----
Timestamp of file with hash 27f463ade22a48024739db23d1039da56bed75cd5631f55b35e5df1c8ebcbea7 -
fbc694a to
bbb07d1
Compare
|
Updated per |
bbb07d1 to
96635e6
Compare
|
Realized that |
Indeed. I hesitated to do something like names.emplace_back("or " + GetNetworkName(NET_UNROUTABLE)); |
maflcko
left a comment
There was a problem hiding this comment.
review ACK 96635e6 🐗
Show signature and timestamp
Signature:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
review ACK 96635e61777add29b6a34d47767a63f43b2919af 🐗
-----BEGIN PGP SIGNATURE-----
iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
pUi1nAv8Co9dfz7Kuxi/uUXJ3ob+y0mhUj0d023QFAyW/2Wh/C+QKZu6HRs8Q8Qh
PG+LNvgT+xfvEZb3bYPUUalSmODqU4OkgkulK1YPCr4zxquExcSFkSFkJL8gZzRu
CyduWAzAfGf2I0lGopqgsHMpfs6Q7SYeoEyXRHjztEzZu2FWZMQEuU5APep5e4q9
tw9Qkw1cfScc0rhROs+GbRj6N8AxA0B+GvvKWvc7Y16RfCIaWlP4vKzwN0s18Lzb
JPKRTTKmasfGHkIgnPCKmR2nlu5z8PekfGtvo5wMrRC5fVsFxedgTrtVuaRBk/Jc
IOM7qdVHvp/ClMvbu78Dm9kTwPTs2yFvg9/XcN57vTNQb4Qme9DJiMzOtELvwgaE
xM3xbwskCTldH6CPwMU7QJtmJxHnsNuO0VmtD7BX4QdCpyGXVXwjoYVpN6yn+/BJ
Ad9EKVDN/OCiC+jXiidgQvy6aiUoev1CEH23zvk3RRLXp+HbqNQfLzJfk6deQ5uF
GAJxcJlJ
=v5MP
-----END PGP SIGNATURE-----
Timestamp of file with hash 946105e795bca254ed011a4ffce2cf299168c362a6c99aed2702782f5738dc7f -
| std::vector<std::string> names; | ||
| for (int n = 0; n < NET_MAX; ++n) { | ||
| const enum Network network{static_cast<Network>(n)}; | ||
| if (network == NET_UNROUTABLE || network == NET_I2P || network == NET_CJDNS || network == NET_INTERNAL) continue; |
There was a problem hiding this comment.
Done in 433d9a9f1e416c5518f832b4ca9402c8807877bc net: Do not skip the I2P network from GetNetworkNames(), thanks for the notice!
…routable, automate helps 96635e6 init: use GetNetworkNames() in -onlynet help (Jon Atack) 0dbde70 rpc: use GetNetworkNames() in getnetworkinfo and getpeerinfo helps (Jon Atack) 1c3af37 net: create GetNetworkNames() (Jon Atack) b45eae4 net: update NET_UNROUTABLE to not_publicly_routable in GetNetworkName() (Jon Atack) Pull request description: per the IRC discussion today at http://www.erisian.com.au/bitcoin-core-dev/log-2021-01-19.html#l-87 - return a more helpful string name for `Network::NET_UNROUTABLE`: "not_publicly_routable" instead of "unroutable" - update the RPC getpeerinfo "network" help, and automate it and the getnetworkinfo "network#name" and the -onlynet help doc generation ACKs for top commit: theStack: re-ACK 96635e6 🌳 MarcoFalke: review ACK 96635e6 🐗 Tree-SHA512: 511a7d987126b48a7a090739aa7c4964b6186a3ff8f5f7eec9233dd816c6b7a6dc91b3ea6b824aa68f218a8a3ebdc6ffd214e9a88af38f2bf23f3257c4284c3a
|
@shesek done, per your original IRC issue getpeerinfo's network field returns (and documents in the help) the |
Github-Pull: bitcoin#20965 Rebased-From: 1c3af37
Summary: > net: update NET_UNROUTABLE to not_publicly_routable in GetNetworkName() > net: create GetNetworkNames() > rpc: use GetNetworkNames() in getnetworkinfo and getpeerinfo helps > init: use GetNetworkNames() in -onlynet help This is a backport of [[bitcoin/bitcoin#20965 | core#20965]] Depends on D11030 Test Plan: `ninja all check-all` Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Subscribers: Fabien Differential Revision: https://reviews.bitcoinabc.org/D11036
per the IRC discussion today at http://www.erisian.com.au/bitcoin-core-dev/log-2021-01-19.html#l-87
Network::NET_UNROUTABLE: "not_publicly_routable" instead of "unroutable"