Skip to content
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

Merged
merged 2 commits into from Feb 2, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/rpcnet.cpp
Expand Up @@ -13,6 +13,7 @@
#include "timedata.h"
#include "util.h"
#include "version.h"
#include "deprecation.h"

#include <boost/foreach.hpp>

Expand Down Expand Up @@ -398,6 +399,33 @@ static UniValue GetNetworksInfo()
return networks;
}

UniValue getdeprecationinfo(const UniValue& params, bool fHelp)
Copy link
Contributor

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.

Copy link
Contributor Author

@arcalinea arcalinea Jan 2, 2018

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.

{
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"
Copy link
Contributor

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.

" \"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));
Copy link
Contributor

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.

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)
Expand Down
1 change: 1 addition & 0 deletions src/rpcserver.cpp
Expand Up @@ -265,6 +265,7 @@ static const CRPCCommand vRPCCommands[] =

/* P2P networking */
{ "network", "getnetworkinfo", &getnetworkinfo, true },
{ "network", "getdeprecationinfo", &getdeprecationinfo, true },
{ "network", "addnode", &addnode, true },
{ "network", "disconnectnode", &disconnectnode, true },
{ "network", "getaddednodeinfo", &getaddednodeinfo, true },
Expand Down
1 change: 1 addition & 0 deletions src/rpcserver.h
Expand Up @@ -238,6 +238,7 @@ extern UniValue getinfo(const UniValue& params, bool fHelp);
extern UniValue getwalletinfo(const UniValue& params, bool fHelp);
extern UniValue getblockchaininfo(const UniValue& params, bool fHelp);
extern UniValue getnetworkinfo(const UniValue& params, bool fHelp);
extern UniValue getdeprecationinfo(const UniValue& params, bool fHelp);
extern UniValue setmocktime(const UniValue& params, bool fHelp);
extern UniValue resendwallettransactions(const UniValue& params, bool fHelp);
extern UniValue zc_benchmark(const UniValue& params, bool fHelp);
Expand Down