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
Add getdeprecationinfo RPC method to return deprecation block height #2839
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.
General utACK, but see comments.
src/rpcnet.cpp
Outdated
"\nResult:\n" | ||
"{\n" | ||
" \"version\": xxxxx, (numeric) the server version\n" | ||
" \"subversion\": \"/MagicBean:x.y.z[-v]/\", (string) the server subversion string\n" |
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.
I find the naming of this irritating (it's an extended representation of the version), but it matches existing Bitcoin-inherited RPCs and API designs, so leave it as-is.
src/rpcnet.cpp
Outdated
"{\n" | ||
" \"version\": xxxxx, (numeric) the server version\n" | ||
" \"subversion\": \"/MagicBean:x.y.z[-v]/\", (string) the server subversion string\n" | ||
" \"deprecationheight\": xxxxx, (numeric) the deprecation block height\n" |
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.
the block height at which this version will deprecate and shut down (unless -disabledeprecation is set)
(modulo line lengths - look at existing RPC help messages for comparison)
@@ -398,6 +399,34 @@ static UniValue GetNetworksInfo() | |||
return networks; | |||
} | |||
|
|||
UniValue getdeprecationinfo(const UniValue& params, bool fHelp) |
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.
Hmm... would this make more sense in rpcmisc.cpp
? If I had to pick a specific category then I would put it in net
, but I think it's closer to upstream's getmemoryinfo
, in that it is about the local node. I'm not fussed about bikeshedding this though.
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.
I put it in rpcnet.cpp
because it also returns version info, duplicating some of what getnetworkinfo
does, so the relevant constants are already imported.
src/rpcnet.cpp
Outdated
+ HelpExampleRpc("getdeprecationinfo", "") | ||
); | ||
|
||
LOCK(cs_main); |
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.
No need to take the lock, as this function only depends on hard-coded constants.
…tion block height.
8513eff
to
9d2974e
Compare
Addressed @str4d's comments |
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.
utACK
src/rpcnet.cpp
Outdated
|
||
|
||
UniValue obj(UniValue::VOBJ); | ||
obj.push_back(Pair("version", CLIENT_VERSION)); |
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.
Remove indentation, since it doesn't align with anything else.
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.
The PR is good... but when running in testnet mode I noticed it was returning me the mainnet deprecation height. Turns out to be an issue with auto-senescence in general, so I filed #2876. In the meantime, getdeprecationinfo
could be made only applicable for mainnet, so consider: (1) updating help message (2) check to see if current network is mainnet or not, and if not, return error message or help message.
Huh, good to know. Ok, will update help message and check for mainnet before showing. |
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.
See comment.
src/rpcnet.cpp
Outdated
UniValue getdeprecationinfo(const UniValue& params, bool fHelp) | ||
{ | ||
const CChainParams& chainparams = Params(); | ||
if (fHelp || params.size() != 0 || chainparams.NetworkIDString() != "mainnet") |
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.
Params().NetworkIDString() != "main"
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. Please merge squash the third commit into the second one.
f5e1e2b
to
df46562
Compare
Squashed |
@zkbot r+ |
📌 Commit df46562 has been approved by |
Add getdeprecationinfo RPC method to return deprecation block height Closes #2828 Returns: ``` { "version": xxxxx, (numeric) the server version "subversion": "/MagicBean:x.y.z[-v]/", (string) the server subversion string "deprecationheight": xxxxx, (numeric) the deprecation block height } ```
Closes #2828
Returns: