mirror of
https://github.com/monero-project/monero.git
synced 2025-01-28 18:56:31 +02:00
Added 'print_height' daemon command
This commit is contained in:
parent
632c60b80f
commit
4a4e3cde94
@ -99,6 +99,13 @@ bool t_command_parser_executor::set_log_level(const std::vector<std::string>& ar
|
||||
return m_executor.set_log_level(l);
|
||||
}
|
||||
|
||||
bool t_command_parser_executor::print_height(const std::vector<std::string>& args)
|
||||
{
|
||||
if (!args.empty()) return false;
|
||||
|
||||
return m_executor.print_height();
|
||||
}
|
||||
|
||||
bool t_command_parser_executor::print_block(const std::vector<std::string>& args)
|
||||
{
|
||||
if (args.empty())
|
||||
|
@ -30,6 +30,8 @@ public:
|
||||
|
||||
bool set_log_level(const std::vector<std::string>& args);
|
||||
|
||||
bool print_height(const std::vector<std::string>& args);
|
||||
|
||||
bool print_block(const std::vector<std::string>& args);
|
||||
|
||||
bool print_transaction(const std::vector<std::string>& args);
|
||||
|
@ -18,6 +18,11 @@ t_command_server::t_command_server(
|
||||
, std::bind(&t_command_server::help, this, p::_1)
|
||||
, "Show this help"
|
||||
);
|
||||
m_command_lookup.set_handler(
|
||||
"print_height"
|
||||
, std::bind(&t_command_parser_executor::print_height, &m_parser, p::_1)
|
||||
, "Print local blockchain height"
|
||||
);
|
||||
m_command_lookup.set_handler(
|
||||
"print_pl"
|
||||
, std::bind(&t_command_parser_executor::print_peer_list, &m_parser, p::_1)
|
||||
|
@ -189,6 +189,18 @@ bool t_rpc_command_executor::set_log_level(int8_t level) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool t_rpc_command_executor::print_height() {
|
||||
cryptonote::COMMAND_RPC_GET_HEIGHT::request req;
|
||||
cryptonote::COMMAND_RPC_GET_HEIGHT::response res;
|
||||
|
||||
if (rpc_request(req, res, "/getheight", "Unsuccessful"))
|
||||
{
|
||||
tools::success_msg_writer() << boost::lexical_cast<std::string>(res.height);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool t_rpc_command_executor::print_block_by_hash(crypto::hash block_hash) {
|
||||
cryptonote::COMMAND_RPC_GET_BLOCK_HEADER_BY_HASH::request req;
|
||||
cryptonote::COMMAND_RPC_GET_BLOCK_HEADER_BY_HASH::response res;
|
||||
|
@ -34,6 +34,8 @@ public:
|
||||
bool print_blockchain_info(uint64_t start_block_index, uint64_t end_block_index);
|
||||
|
||||
bool set_log_level(int8_t level);
|
||||
|
||||
bool print_height();
|
||||
|
||||
bool print_block_by_hash(crypto::hash block_hash);
|
||||
|
||||
@ -51,6 +53,7 @@ public:
|
||||
|
||||
bool stop_daemon();
|
||||
|
||||
|
||||
private:
|
||||
template <typename T_req, typename T_res>
|
||||
bool json_rpc_request(
|
||||
|
Loading…
Reference in New Issue
Block a user