diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2015-09-19 16:34:29 +0100 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2015-09-19 16:47:48 +0100 |
commit | e546f3724aeb91e72df263c27780a4d149b0a92a (patch) | |
tree | 76b560fca57fedc410af0d6e3cdec526fc8ed420 /src/daemon | |
parent | blockchain: force a hardfork recalculation at load time (diff) | |
download | monero-e546f3724aeb91e72df263c27780a4d149b0a92a.tar.xz |
Add an RPC call and daemon command to get info on hard fork voting
Diffstat (limited to 'src/daemon')
-rw-r--r-- | src/daemon/command_parser_executor.cpp | 22 | ||||
-rw-r--r-- | src/daemon/command_parser_executor.h | 2 | ||||
-rw-r--r-- | src/daemon/command_server.cpp | 5 | ||||
-rw-r--r-- | src/daemon/rpc_command_executor.cpp | 31 | ||||
-rw-r--r-- | src/daemon/rpc_command_executor.h | 2 |
5 files changed, 62 insertions, 0 deletions
diff --git a/src/daemon/command_parser_executor.cpp b/src/daemon/command_parser_executor.cpp index e6666c443..7b0f4a66b 100644 --- a/src/daemon/command_parser_executor.cpp +++ b/src/daemon/command_parser_executor.cpp @@ -361,5 +361,27 @@ bool t_command_parser_executor::stop_save_graph(const std::vector<std::string>& return m_executor.stop_save_graph(); } +bool t_command_parser_executor::hard_fork_info(const std::vector<std::string>& args) +{ + int version; + if (args.size() == 0) { + version = 0; + } + else if (args.size() == 1) { + try { + version = std::stoi(args[0]); + } + catch(std::invalid_argument& ex) { + return false; + } + if (version <= 0 || version > 255) + return false; + } + else { + return false; + } + return m_executor.hard_fork_info(version); +} + } // namespace daemonize diff --git a/src/daemon/command_parser_executor.h b/src/daemon/command_parser_executor.h index ddc207cfe..f900c72bd 100644 --- a/src/daemon/command_parser_executor.h +++ b/src/daemon/command_parser_executor.h @@ -102,6 +102,8 @@ public: bool start_save_graph(const std::vector<std::string>& args); bool stop_save_graph(const std::vector<std::string>& args); + + bool hard_fork_info(const std::vector<std::string>& args); }; } // namespace daemonize diff --git a/src/daemon/command_server.cpp b/src/daemon/command_server.cpp index 047b52c3e..446379558 100644 --- a/src/daemon/command_server.cpp +++ b/src/daemon/command_server.cpp @@ -184,6 +184,11 @@ t_command_server::t_command_server( , std::bind(&t_command_parser_executor::stop_save_graph, &m_parser, p::_1) , "Stop save data for dr monero" ); + m_command_lookup.set_handler( + "hard_fork_info" + , std::bind(&t_command_parser_executor::hard_fork_info, &m_parser, p::_1) + , "Print hard fork voting information" + ); } bool t_command_server::process_command_str(const std::string& cmd) diff --git a/src/daemon/rpc_command_executor.cpp b/src/daemon/rpc_command_executor.cpp index 62f254c76..c4fe642e8 100644 --- a/src/daemon/rpc_command_executor.cpp +++ b/src/daemon/rpc_command_executor.cpp @@ -946,4 +946,35 @@ bool t_rpc_command_executor::stop_save_graph() return true; } +bool t_rpc_command_executor::hard_fork_info(uint8_t version) +{ + cryptonote::COMMAND_RPC_HARD_FORK_INFO::request req; + cryptonote::COMMAND_RPC_HARD_FORK_INFO::response res; + std::string fail_message = "Unsuccessful"; + epee::json_rpc::error error_resp; + + req.version = version; + + if (m_is_rpc) + { + if (!m_rpc_client->json_rpc_request(req, res, "/hard_fork_info", fail_message.c_str())) + { + return true; + } + } + else + { + if (!m_rpc_server->on_hard_fork_info(req, res, error_resp)) + { + tools::fail_msg_writer() << fail_message.c_str(); + return true; + } + version = version > 0 ? version : res.voting; + tools::msg_writer() << "version " << (uint32_t)version << " " << (res.enabled ? "enabled" : "not enabled") << + ", " << res.votes << "/" << res.window << " votes, threshold " << res.threshold; + tools::msg_writer() << "current version " << (uint32_t)res.version << ", voting for version " << (uint32_t)res.voting; + } + return true; +} + }// namespace daemonize diff --git a/src/daemon/rpc_command_executor.h b/src/daemon/rpc_command_executor.h index b40a67bf8..9ad849434 100644 --- a/src/daemon/rpc_command_executor.h +++ b/src/daemon/rpc_command_executor.h @@ -120,6 +120,8 @@ public: bool start_save_graph(); bool stop_save_graph(); + + bool hard_fork_info(uint8_t version); }; } // namespace daemonize |