aboutsummaryrefslogtreecommitdiff
path: root/src/daemon/rpc_command_executor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/daemon/rpc_command_executor.cpp')
-rw-r--r--src/daemon/rpc_command_executor.cpp62
1 files changed, 20 insertions, 42 deletions
diff --git a/src/daemon/rpc_command_executor.cpp b/src/daemon/rpc_command_executor.cpp
index ad6041fca..e7229f7f9 100644
--- a/src/daemon/rpc_command_executor.cpp
+++ b/src/daemon/rpc_command_executor.cpp
@@ -57,7 +57,7 @@ namespace {
tools::msg_writer() << boost::format("%-10s %-25s %-25s %s") % prefix % id_str % addr_str % elapsed;
}
- void print_block_header(cryptonote::block_header_responce const & header)
+ void print_block_header(cryptonote::block_header_response const & header)
{
tools::success_msg_writer()
<< "timestamp: " << boost::lexical_cast<std::string>(header.timestamp) << std::endl
@@ -296,6 +296,16 @@ static std::string get_fork_extra_info(uint64_t t, uint64_t now, uint64_t block_
return "";
}
+static float get_sync_percentage(const cryptonote::COMMAND_RPC_GET_INFO::response &ires)
+{
+ uint64_t height = ires.height;
+ uint64_t target_height = ires.target_height ? ires.target_height < ires.height ? ires.height : ires.target_height : ires.height;
+ float pc = 100.0f * height / target_height;
+ if (height < target_height && pc > 99.9f)
+ return 99.9f; // to avoid 100% when not fully synced
+ return pc;
+}
+
bool t_rpc_command_executor::show_status() {
cryptonote::COMMAND_RPC_GET_INFO::request ireq;
cryptonote::COMMAND_RPC_GET_INFO::response ires;
@@ -356,7 +366,7 @@ bool t_rpc_command_executor::show_status() {
tools::success_msg_writer() << boost::format("Height: %llu/%llu (%.1f%%) on %s, %s, net hash %s, v%u%s, %s, %u+%u connections")
% (unsigned long long)ires.height
% (unsigned long long)(ires.target_height >= ires.height ? ires.target_height : ires.height)
- % (100.0f * ires.height / (ires.target_height ? ires.target_height < ires.height ? ires.height : ires.target_height : ires.height))
+ % get_sync_percentage(ires)
% (ires.testnet ? "testnet" : "mainnet")
% (mining_busy ? "syncing" : mres.active ? "mining at " + get_mining_speed(mres.speed) : "not mining")
% get_mining_speed(ires.difficulty / ires.target)
@@ -430,11 +440,6 @@ bool t_rpc_command_executor::print_connections() {
}
bool t_rpc_command_executor::print_blockchain_info(uint64_t start_block_index, uint64_t end_block_index) {
-
-// this function appears to not exist in the json rpc api, and so is commented
-// until such a time as it does.
-
-/*
cryptonote::COMMAND_RPC_GET_BLOCK_HEADERS_RANGE::request req;
cryptonote::COMMAND_RPC_GET_BLOCK_HEADERS_RANGE::response res;
epee::json_rpc::error error_resp;
@@ -453,25 +458,26 @@ bool t_rpc_command_executor::print_blockchain_info(uint64_t start_block_index, u
}
else
{
- if (!m_rpc_server->on_getblockheadersrange(req, res, error_resp) || res.status != CORE_RPC_STATUS_OK)
+ if (!m_rpc_server->on_get_block_headers_range(req, res, error_resp) || res.status != CORE_RPC_STATUS_OK)
{
tools::fail_msg_writer() << fail_message.c_str();
return true;
}
}
+ bool first = true;
for (auto & header : res.headers)
{
+ if (!first)
+ std::cout << std::endl;
std::cout
- << "major version: " << header.major_version << std::endl
- << "minor version: " << header.minor_version << std::endl
+ << "major version: " << (unsigned)header.major_version << ", minor version: " << (unsigned)header.minor_version << std::endl
<< "height: " << header.height << ", timestamp: " << header.timestamp << ", difficulty: " << header.difficulty << std::endl
- << "block id: " << header.hash << std::endl
- << "previous block id: " << header.prev_hash << std::endl
- << "difficulty: " << header.difficulty << ", nonce " << header.nonce << std::endl;
+ << "block id: " << header.hash << ", previous block id: " << header.prev_hash << std::endl
+ << "difficulty: " << header.difficulty << ", nonce " << header.nonce << ", reward " << cryptonote::print_money(header.reward) << std::endl;
+ first = false;
}
-*/
return true;
}
@@ -979,34 +985,6 @@ bool t_rpc_command_executor::set_limit_down(int limit)
return true;
}
-bool t_rpc_command_executor::fast_exit()
-{
- cryptonote::COMMAND_RPC_FAST_EXIT::request req;
- cryptonote::COMMAND_RPC_FAST_EXIT::response res;
-
- std::string fail_message = "Daemon did not stop";
-
- if (m_is_rpc)
- {
- if (!m_rpc_client->rpc_request(req, res, "/fast_exit", fail_message.c_str()))
- {
- return true;
- }
- }
-
- else
- {
- if (!m_rpc_server->on_fast_exit(req, res) || res.status != CORE_RPC_STATUS_OK)
- {
- tools::fail_msg_writer() << fail_message.c_str();
- return true;
- }
- }
-
- tools::success_msg_writer() << "Daemon stopped";
- return true;
-}
-
bool t_rpc_command_executor::out_peers(uint64_t limit)
{
cryptonote::COMMAND_RPC_OUT_PEERS::request req;