diff options
author | Zachary Michaels <mikezackles@gmail.com> | 2014-07-22 14:00:10 -0400 |
---|---|---|
committer | Zachary Michaels <mikezackles@gmail.com> | 2014-07-22 14:00:10 -0400 |
commit | 2796a7f015956e11aec847e39fc0e214714af534 (patch) | |
tree | 2c06b3fbe708fc5350e72abc187e8e21a98cbcda /src/rpc/core_rpc_server.cpp | |
parent | Add get_bulk_payments rpc call (diff) | |
download | monero-2796a7f015956e11aec847e39fc0e214714af534.tar.xz |
Add get_info command to daemon json rpc
Diffstat (limited to 'src/rpc/core_rpc_server.cpp')
-rw-r--r-- | src/rpc/core_rpc_server.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp index 1334b5137..abf30938f 100644 --- a/src/rpc/core_rpc_server.cpp +++ b/src/rpc/core_rpc_server.cpp @@ -620,4 +620,28 @@ namespace cryptonote return true; } //------------------------------------------------------------------------------------------------------------------------------ + bool core_rpc_server::on_get_info_json(const COMMAND_RPC_GET_INFO::request& req, COMMAND_RPC_GET_INFO::response& res, epee::json_rpc::error& error_resp, connection_context& cntx) + { + if(!check_core_busy()) + { + error_resp.code = CORE_RPC_ERROR_CODE_CORE_BUSY; + error_resp.message = "Core is busy."; + return false; + } + + res.height = m_core.get_current_blockchain_height(); + res.target_height = m_core.get_target_blockchain_height(); + res.difficulty = m_core.get_blockchain_storage().get_difficulty_for_next_block(); + res.tx_count = m_core.get_blockchain_storage().get_total_transactions() - res.height; //without coinbase + res.tx_pool_size = m_core.get_pool_transactions_count(); + res.alt_blocks_count = m_core.get_blockchain_storage().get_alternative_blocks_count(); + uint64_t total_conn = m_p2p.get_connections_count(); + res.outgoing_connections_count = m_p2p.get_outgoing_connections_count(); + res.incoming_connections_count = total_conn - res.outgoing_connections_count; + 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.status = CORE_RPC_STATUS_OK; + return true; + } + //------------------------------------------------------------------------------------------------------------------------------ } |