aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2017-03-18 20:31:12 +0200
committerRiccardo Spagni <ric@spagni.net>2017-03-18 20:31:12 +0200
commita48e41787b5198a6fc51d39e31a7873a05598c53 (patch)
treec94735ce42a58f4b36a61cad01382ddbfd3ab458 /src
parentMerge pull request #1884 (diff)
parentdaemon: alt_chain_info now prints fork depth (diff)
downloadmonero-a48e41787b5198a6fc51d39e31a7873a05598c53.tar.xz
Merge pull request #1885
63d7cd88 daemon: alt_chain_info now prints fork depth (moneromooo-monero)
Diffstat (limited to 'src')
-rw-r--r--src/daemon/rpc_command_executor.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/daemon/rpc_command_executor.cpp b/src/daemon/rpc_command_executor.cpp
index e9f95ae6b..037d10b7d 100644
--- a/src/daemon/rpc_command_executor.cpp
+++ b/src/daemon/rpc_command_executor.cpp
@@ -1444,6 +1444,8 @@ bool t_rpc_command_executor::print_coinbase_tx_sum(uint64_t height, uint64_t cou
bool t_rpc_command_executor::alt_chain_info()
{
+ cryptonote::COMMAND_RPC_GET_INFO::request ireq;
+ cryptonote::COMMAND_RPC_GET_INFO::response ires;
cryptonote::COMMAND_RPC_GET_ALTERNATE_CHAINS::request req;
cryptonote::COMMAND_RPC_GET_ALTERNATE_CHAINS::response res;
epee::json_rpc::error error_resp;
@@ -1452,6 +1454,10 @@ bool t_rpc_command_executor::alt_chain_info()
if (m_is_rpc)
{
+ if (!m_rpc_client->rpc_request(ireq, ires, "/getinfo", fail_message.c_str()))
+ {
+ return true;
+ }
if (!m_rpc_client->json_rpc_request(req, res, "get_alternate_chains", fail_message.c_str()))
{
return true;
@@ -1459,6 +1465,11 @@ bool t_rpc_command_executor::alt_chain_info()
}
else
{
+ if (!m_rpc_server->on_get_info(ireq, ires) || ires.status != CORE_RPC_STATUS_OK)
+ {
+ tools::fail_msg_writer() << fail_message.c_str();
+ return true;
+ }
if (!m_rpc_server->on_get_alternate_chains(req, res, error_resp))
{
tools::fail_msg_writer() << fail_message.c_str();
@@ -1469,8 +1480,9 @@ bool t_rpc_command_executor::alt_chain_info()
tools::msg_writer() << boost::lexical_cast<std::string>(res.chains.size()) << " alternate chains found:";
for (const auto chain: res.chains)
{
- tools::msg_writer() << chain.length << " blocks long, branching at height " << (chain.height - chain.length + 1)
- << ", difficulty " << chain.difficulty << ": " << chain.block_hash;
+ uint64_t start_height = (chain.height - chain.length + 1);
+ tools::msg_writer() << chain.length << " blocks long, from height " << start_height << " (" << (ires.height - start_height - 1)
+ << " deep, diff " << chain.difficulty << ": " << chain.block_hash;
}
return true;
}