diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2017-03-18 16:59:57 +0000 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2017-03-18 16:59:57 +0000 |
commit | 63d7cd8882008fad813b7168b6b7bc4a40eea41f (patch) | |
tree | 728533c7d3a5900070bc1a8f76c6bc7ba6eff937 /src/daemon/rpc_command_executor.cpp | |
parent | Merge pull request #1869 (diff) | |
download | monero-63d7cd8882008fad813b7168b6b7bc4a40eea41f.tar.xz |
daemon: alt_chain_info now prints fork depth
Diffstat (limited to '')
-rw-r--r-- | src/daemon/rpc_command_executor.cpp | 16 |
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; } |