diff options
Diffstat (limited to 'src/rpc')
-rw-r--r-- | src/rpc/core_rpc_server.cpp | 11 | ||||
-rw-r--r-- | src/rpc/core_rpc_server_commands_defs.h | 2 |
2 files changed, 12 insertions, 1 deletions
diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp index f5258268c..0fca2eb57 100644 --- a/src/rpc/core_rpc_server.cpp +++ b/src/rpc/core_rpc_server.cpp @@ -142,6 +142,7 @@ namespace cryptonote res.white_peerlist_size = m_p2p.get_peerlist_manager().get_white_peers_count(); res.grey_peerlist_size = m_p2p.get_peerlist_manager().get_gray_peers_count(); res.testnet = m_testnet; + res.cumulative_difficulty = m_core.get_blockchain_storage().get_db().get_block_cumulative_difficulty(res.height - 1); res.status = CORE_RPC_STATUS_OK; return true; } @@ -1092,7 +1093,14 @@ namespace cryptonote return false; } - 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_V2; @@ -1105,6 +1113,7 @@ namespace cryptonote res.white_peerlist_size = m_p2p.get_peerlist_manager().get_white_peers_count(); res.grey_peerlist_size = m_p2p.get_peerlist_manager().get_gray_peers_count(); res.testnet = m_testnet; + res.cumulative_difficulty = m_core.get_blockchain_storage().get_db().get_block_cumulative_difficulty(res.height - 1); res.status = CORE_RPC_STATUS_OK; return true; } diff --git a/src/rpc/core_rpc_server_commands_defs.h b/src/rpc/core_rpc_server_commands_defs.h index cb58d0d07..85895a71a 100644 --- a/src/rpc/core_rpc_server_commands_defs.h +++ b/src/rpc/core_rpc_server_commands_defs.h @@ -464,6 +464,7 @@ namespace cryptonote uint64_t grey_peerlist_size; bool testnet; std::string top_block_hash; + uint64_t cumulative_difficulty; BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(status) @@ -480,6 +481,7 @@ namespace cryptonote KV_SERIALIZE(grey_peerlist_size) KV_SERIALIZE(testnet) KV_SERIALIZE(top_block_hash) + KV_SERIALIZE(cumulative_difficulty) END_KV_SERIALIZE_MAP() }; }; |