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

Fix broken height_MoM RPC #9

Merged
merged 1 commit into from
Aug 5, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions src/rpc/blockchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2784,7 +2784,6 @@ static RPCHelpMan calc_MoM()
MoMdepth = atoi(request.params[1].get_str().c_str());
if ( height <= 0 || MoMdepth <= 0 || MoMdepth >= height )
throw std::runtime_error("calc_MoM illegal height or MoMdepth\n");
//fprintf(stderr,"height_MoM height.%d\n",height);
MoM = komodo_calcMoM(height,MoMdepth);
ret.pushKV("coin",(char *)(ASSETCHAINS_SYMBOL[0] == 0 ? "KMD" : ASSETCHAINS_SYMBOL));
ret.pushKV("height",height);
Expand All @@ -2798,13 +2797,29 @@ static RPCHelpMan calc_MoM()
static RPCHelpMan height_MoM()
{
return RPCHelpMan{"height_MoM",
"\n",
{},
"Calculates MoM for a given height, if it exists\n",
{
{"height", RPCArg::Type::NUM, RPCArg::Optional::NO, "height for MoM calculation"},
},
RPCResult{
RPCResult::Type::NUM, "", "The current block count"},
RPCResult::Type::OBJ, "", "",
{
{RPCResult::Type::STR, "coin", "active coin"},
{RPCResult::Type::NUM, "height", "requested block height"},
{RPCResult::Type::NUM, "timestamp", "timestamp"},
{RPCResult::Type::NUM, "depth", "MoMdepth"},
{RPCResult::Type::NUM, "notarized_height", "height of last notarization"},
{RPCResult::Type::STR_HEX, "MoM", "MoM hash"},
{RPCResult::Type::STR_HEX, "kmdtxid", "txid from komodo"},
{RPCResult::Type::STR_HEX, "MoMoM", "MoMoM hash"},
{RPCResult::Type::NUM, "MoMoMoffset", "MoMoffset"},
{RPCResult::Type::NUM, "kmdstarti", "kmdstarti"},
{RPCResult::Type::NUM, "kmdendi", "kmdendi"},
}
},
RPCExamples{
HelpExampleCli("getblockcount", "")
+ HelpExampleRpc("getblockcount", "")
HelpExampleCli("height_MoM", "100")
+ HelpExampleRpc("height_MoM", "100")
},
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
{
Expand Down