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);
|
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)
|
bool t_command_parser_executor::print_block(const std::vector<std::string>& args)
|
||||||
{
|
{
|
||||||
if (args.empty())
|
if (args.empty())
|
||||||
|
@ -30,6 +30,8 @@ public:
|
|||||||
|
|
||||||
bool set_log_level(const std::vector<std::string>& args);
|
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_block(const std::vector<std::string>& args);
|
||||||
|
|
||||||
bool print_transaction(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)
|
, std::bind(&t_command_server::help, this, p::_1)
|
||||||
, "Show this help"
|
, "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(
|
m_command_lookup.set_handler(
|
||||||
"print_pl"
|
"print_pl"
|
||||||
, std::bind(&t_command_parser_executor::print_peer_list, &m_parser, p::_1)
|
, 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;
|
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) {
|
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::request req;
|
||||||
cryptonote::COMMAND_RPC_GET_BLOCK_HEADER_BY_HASH::response res;
|
cryptonote::COMMAND_RPC_GET_BLOCK_HEADER_BY_HASH::response res;
|
||||||
|
@ -35,6 +35,8 @@ public:
|
|||||||
|
|
||||||
bool set_log_level(int8_t level);
|
bool set_log_level(int8_t level);
|
||||||
|
|
||||||
|
bool print_height();
|
||||||
|
|
||||||
bool print_block_by_hash(crypto::hash block_hash);
|
bool print_block_by_hash(crypto::hash block_hash);
|
||||||
|
|
||||||
bool print_block_by_height(uint64_t height);
|
bool print_block_by_height(uint64_t height);
|
||||||
@ -51,6 +53,7 @@ public:
|
|||||||
|
|
||||||
bool stop_daemon();
|
bool stop_daemon();
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
template <typename T_req, typename T_res>
|
template <typename T_req, typename T_res>
|
||||||
bool json_rpc_request(
|
bool json_rpc_request(
|
||||||
|
Loading…
Reference in New Issue
Block a user