aboutsummaryrefslogtreecommitdiff
path: root/src/rpc
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2015-12-18 19:56:17 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2015-12-18 19:56:17 +0000
commit0ab56b80dbf59ecc9877a055ced3c46dda501646 (patch)
treeb27341e7226da5763c66f5f5d999c03b6fc1f7c2 /src/rpc
parentMerge pull request #541 (diff)
downloadmonero-0ab56b80dbf59ecc9877a055ced3c46dda501646.tar.xz
print top block hash in daemon diff command
and add top block hash in get_info RPC
Diffstat (limited to 'src/rpc')
-rw-r--r--src/rpc/core_rpc_server.cpp9
-rw-r--r--src/rpc/core_rpc_server_commands_defs.h2
2 files changed, 10 insertions, 1 deletions
diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp
index b566e7318..945557a46 100644
--- a/src/rpc/core_rpc_server.cpp
+++ b/src/rpc/core_rpc_server.cpp
@@ -117,7 +117,14 @@ namespace cryptonote
bool core_rpc_server::on_get_info(const COMMAND_RPC_GET_INFO::request& req, COMMAND_RPC_GET_INFO::response& res)
{
CHECK_CORE_BUSY();
- res.height = m_core.get_current_blockchain_height();
+ crypto::hash top_hash;
+ if (!m_core.get_blockchain_top(res.height, top_hash))
+ {
+ res.status = "Failed";
+ return false;
+ }
+ ++res.height; // turn top block height into blockchain height
+ res.top_block_hash = string_tools::pod_to_hex(top_hash);
res.target_height = m_core.get_target_blockchain_height();
res.difficulty = m_core.get_blockchain_storage().get_difficulty_for_next_block();
res.target = m_core.get_blockchain_storage().get_current_hard_fork_version() < 2 ? DIFFICULTY_TARGET_V1 : DIFFICULTY_TARGET;
diff --git a/src/rpc/core_rpc_server_commands_defs.h b/src/rpc/core_rpc_server_commands_defs.h
index b70164614..73cdbbe07 100644
--- a/src/rpc/core_rpc_server_commands_defs.h
+++ b/src/rpc/core_rpc_server_commands_defs.h
@@ -282,6 +282,7 @@ namespace cryptonote
uint64_t white_peerlist_size;
uint64_t grey_peerlist_size;
bool testnet;
+ std::string top_block_hash;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(status)
@@ -296,6 +297,7 @@ namespace cryptonote
KV_SERIALIZE(white_peerlist_size)
KV_SERIALIZE(grey_peerlist_size)
KV_SERIALIZE(testnet)
+ KV_SERIALIZE(top_block_hash)
END_KV_SERIALIZE_MAP()
};
};