diff options
author | Riccardo Spagni <ric@spagni.net> | 2018-02-16 14:18:50 +0100 |
---|---|---|
committer | Riccardo Spagni <ric@spagni.net> | 2018-02-16 14:18:50 +0100 |
commit | 04a676397f57e1f5adf6a994b2d83942550f5109 (patch) | |
tree | 95be9cb9e1698e8fd8bf98fcb6b2acfd11a29b81 /src/daemon/rpc_command_executor.cpp | |
parent | Merge pull request #3163 (diff) | |
parent | Bootstrap daemon (diff) | |
download | monero-04a676397f57e1f5adf6a994b2d83942550f5109.tar.xz |
Merge pull request #3165
7539603f Bootstrap daemon (stoffu)
Diffstat (limited to 'src/daemon/rpc_command_executor.cpp')
-rw-r--r-- | src/daemon/rpc_command_executor.cpp | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/src/daemon/rpc_command_executor.cpp b/src/daemon/rpc_command_executor.cpp index 0ae0fd2cc..5ef799d40 100644 --- a/src/daemon/rpc_command_executor.cpp +++ b/src/daemon/rpc_command_executor.cpp @@ -353,15 +353,18 @@ 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) +static float get_sync_percentage(uint64_t height, uint64_t target_height) { - uint64_t height = ires.height; - uint64_t target_height = ires.target_height ? ires.target_height < ires.height ? ires.height : ires.target_height : ires.height; + target_height = target_height ? target_height < height ? height : target_height : 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; } +static float get_sync_percentage(const cryptonote::COMMAND_RPC_GET_INFO::response &ires) +{ + return get_sync_percentage(ires.height, ires.target_height); +} bool t_rpc_command_executor::show_status() { cryptonote::COMMAND_RPC_GET_INFO::request ireq; @@ -421,12 +424,26 @@ bool t_rpc_command_executor::show_status() { std::time_t uptime = std::time(nullptr) - ires.start_time; uint64_t net_height = ires.target_height > ires.height ? ires.target_height : ires.height; + std::string bootstrap_msg; + if (ires.was_bootstrap_ever_used) + { + bootstrap_msg = ", bootstrapping from " + ires.bootstrap_daemon_address; + if (ires.untrusted) + { + bootstrap_msg += (boost::format(", local height: %llu (%.1f%%)") % ires.height_without_bootstrap % get_sync_percentage(ires.height_without_bootstrap, net_height)).str(); + } + else + { + bootstrap_msg += " was used before"; + } + } - tools::success_msg_writer() << boost::format("Height: %llu/%llu (%.1f%%) on %s, %s, net hash %s, v%u%s, %s, %u(out)+%u(in) connections, uptime %ud %uh %um %us") + tools::success_msg_writer() << boost::format("Height: %llu/%llu (%.1f%%) on %s%s, %s, net hash %s, v%u%s, %s, %u(out)+%u(in) connections, uptime %ud %uh %um %us") % (unsigned long long)ires.height % (unsigned long long)net_height % get_sync_percentage(ires) % (ires.testnet ? "testnet" : "mainnet") + % bootstrap_msg % (!has_mining_info ? "mining info unavailable" : mining_busy ? "syncing" : mres.active ? ( ( mres.is_background_mining_enabled ? "smart " : "" ) + std::string("mining at ") + get_mining_speed(mres.speed) ) : "not mining") % get_mining_speed(ires.difficulty / ires.target) % (unsigned)hfres.version |