aboutsummaryrefslogtreecommitdiff
path: root/src/rpc
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2015-09-19 16:34:29 +0100
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2015-09-19 16:47:48 +0100
commite546f3724aeb91e72df263c27780a4d149b0a92a (patch)
tree76b560fca57fedc410af0d6e3cdec526fc8ed420 /src/rpc
parentblockchain: force a hardfork recalculation at load time (diff)
downloadmonero-e546f3724aeb91e72df263c27780a4d149b0a92a.tar.xz
Add an RPC call and daemon command to get info on hard fork voting
Diffstat (limited to 'src/rpc')
-rw-r--r--src/rpc/core_rpc_server.cpp23
-rw-r--r--src/rpc/core_rpc_server.h1
-rw-r--r--src/rpc/core_rpc_server_commands_defs.h35
-rw-r--r--src/rpc/core_rpc_server_error_codes.h1
4 files changed, 60 insertions, 0 deletions
diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp
index 80bd7e6cd..f9ff632ac 100644
--- a/src/rpc/core_rpc_server.cpp
+++ b/src/rpc/core_rpc_server.cpp
@@ -812,6 +812,29 @@ namespace cryptonote
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
+ bool core_rpc_server::on_hard_fork_info(const COMMAND_RPC_HARD_FORK_INFO::request& req, COMMAND_RPC_HARD_FORK_INFO::response& res, epee::json_rpc::error& error_resp)
+ {
+ if(!check_core_busy())
+ {
+ error_resp.code = CORE_RPC_ERROR_CODE_CORE_BUSY;
+ error_resp.message = "Core is busy.";
+ return false;
+ }
+
+#if BLOCKCHAIN_DB == DB_LMDB
+ const Blockchain &blockchain = m_core.get_blockchain_storage();
+ uint8_t version = req.version > 0 ? req.version : blockchain.get_ideal_hard_fork_version();
+ res.version = blockchain.get_current_hard_fork_version();
+ res.enabled = blockchain.get_hard_fork_voting_info(version, res.window, res.votes, res.threshold, res.voting);
+ res.state = blockchain.get_hard_fork_state();
+ return true;
+#else
+ error_resp.code = CORE_RPC_ERROR_CODE_UNSUPPORTED_RPC;
+ error_resp.message = "Hard fork inoperative in memory mode.";
+ return false;
+#endif
+ }
+ //------------------------------------------------------------------------------------------------------------------------------
bool core_rpc_server::on_fast_exit(const COMMAND_RPC_FAST_EXIT::request& req, COMMAND_RPC_FAST_EXIT::response& res)
{
cryptonote::core::set_fast_exit();
diff --git a/src/rpc/core_rpc_server.h b/src/rpc/core_rpc_server.h
index 3213e6b1c..60e7d00d5 100644
--- a/src/rpc/core_rpc_server.h
+++ b/src/rpc/core_rpc_server.h
@@ -138,6 +138,7 @@ namespace cryptonote
bool on_get_block_header_by_height(const COMMAND_RPC_GET_BLOCK_HEADER_BY_HEIGHT::request& req, COMMAND_RPC_GET_BLOCK_HEADER_BY_HEIGHT::response& res, epee::json_rpc::error& error_resp);
bool on_get_connections(const COMMAND_RPC_GET_CONNECTIONS::request& req, COMMAND_RPC_GET_CONNECTIONS::response& res, epee::json_rpc::error& error_resp);
bool on_get_info_json(const COMMAND_RPC_GET_INFO::request& req, COMMAND_RPC_GET_INFO::response& res, epee::json_rpc::error& error_resp);
+ bool on_hard_fork_info(const COMMAND_RPC_HARD_FORK_INFO::request& req, COMMAND_RPC_HARD_FORK_INFO::response& res, epee::json_rpc::error& error_resp);
//-----------------------
private:
diff --git a/src/rpc/core_rpc_server_commands_defs.h b/src/rpc/core_rpc_server_commands_defs.h
index b2fdd9930..a806cbae9 100644
--- a/src/rpc/core_rpc_server_commands_defs.h
+++ b/src/rpc/core_rpc_server_commands_defs.h
@@ -815,5 +815,40 @@ namespace cryptonote
END_KV_SERIALIZE_MAP()
};
};
+
+ struct COMMAND_RPC_HARD_FORK_INFO
+ {
+ struct request
+ {
+ uint8_t version;
+
+ BEGIN_KV_SERIALIZE_MAP()
+ KV_SERIALIZE(version)
+ END_KV_SERIALIZE_MAP()
+ };
+
+ struct response
+ {
+ uint8_t version;
+ bool enabled;
+ uint32_t window;
+ uint32_t votes;
+ uint32_t threshold;
+ uint8_t voting;
+ uint32_t state;
+ std::string status;
+
+ BEGIN_KV_SERIALIZE_MAP()
+ KV_SERIALIZE(version)
+ KV_SERIALIZE(enabled)
+ KV_SERIALIZE(window)
+ KV_SERIALIZE(votes)
+ KV_SERIALIZE(threshold)
+ KV_SERIALIZE(voting)
+ KV_SERIALIZE(state)
+ KV_SERIALIZE(status)
+ END_KV_SERIALIZE_MAP()
+ };
+ };
}
diff --git a/src/rpc/core_rpc_server_error_codes.h b/src/rpc/core_rpc_server_error_codes.h
index 91659eb2a..72c72b94b 100644
--- a/src/rpc/core_rpc_server_error_codes.h
+++ b/src/rpc/core_rpc_server_error_codes.h
@@ -40,5 +40,6 @@
#define CORE_RPC_ERROR_CODE_BLOCK_NOT_ACCEPTED -7
#define CORE_RPC_ERROR_CODE_CORE_BUSY -9
#define CORE_RPC_ERROR_CODE_WRONG_BLOCKBLOB_SIZE -10
+#define CORE_RPC_ERROR_CODE_UNSUPPORTED_RPC -11