diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2016-09-24 11:38:58 +0100 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2016-09-24 11:45:19 +0100 |
commit | 8b4e7c6c9c4a0c77d507aa74c748841c025660b4 (patch) | |
tree | 6e897ea5cdf61751a14393e9f49d7176796ff06f /src/daemon/rpc_command_executor.cpp | |
parent | Merge pull request #1102 (diff) | |
download | monero-8b4e7c6c9c4a0c77d507aa74c748841c025660b4.tar.xz |
daemon: report status at 99.9% rather than 100% when not quite synced
Less confusing for users.
Diffstat (limited to 'src/daemon/rpc_command_executor.cpp')
-rw-r--r-- | src/daemon/rpc_command_executor.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/daemon/rpc_command_executor.cpp b/src/daemon/rpc_command_executor.cpp index ad6041fca..67e51398c 100644 --- a/src/daemon/rpc_command_executor.cpp +++ b/src/daemon/rpc_command_executor.cpp @@ -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) |