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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ | |
#include "timedata.h" | ||
#include "util.h" | ||
#include "version.h" | ||
#include "deprecation.h" | ||
|
||
#include <boost/foreach.hpp> | ||
|
||
|
@@ -398,6 +399,33 @@ static UniValue GetNetworksInfo() | |
return networks; | ||
} | ||
|
||
UniValue getdeprecationinfo(const UniValue& params, bool fHelp) | ||
{ | ||
if (fHelp || params.size() != 0) | ||
throw runtime_error( | ||
"getdeprecationinfo\n" | ||
"Returns an object containing current version and deprecation block height.\n" | ||
"\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 commentThe 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. |
||
" \"deprecationheight\": xxxxx, (numeric) the block height at which this version will deprecate and shut down (unless -disabledeprecation is set)\n" | ||
"}\n" | ||
"\nExamples:\n" | ||
+ HelpExampleCli("getdeprecationinfo", "") | ||
+ HelpExampleRpc("getdeprecationinfo", "") | ||
); | ||
|
||
|
||
UniValue obj(UniValue::VOBJ); | ||
obj.push_back(Pair("version", CLIENT_VERSION)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove indentation, since it doesn't align with anything else. |
||
obj.push_back(Pair("subversion", | ||
FormatSubVersion(CLIENT_NAME, CLIENT_VERSION, std::vector<string>()))); | ||
obj.push_back(Pair("deprecationheight", DEPRECATION_HEIGHT)); | ||
|
||
return obj; | ||
} | ||
|
||
UniValue getnetworkinfo(const UniValue& params, bool fHelp) | ||
{ | ||
if (fHelp || params.size() != 0) | ||
|
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 innet
, but I think it's closer to upstream'sgetmemoryinfo
, 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 whatgetnetworkinfo
does, so the relevant constants are already imported.