aboutsummaryrefslogtreecommitdiff
path: root/src/rpc/core_rpc_server.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/rpc/core_rpc_server.cpp')
-rw-r--r--src/rpc/core_rpc_server.cpp65
1 files changed, 3 insertions, 62 deletions
diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp
index 2e7ef3e1b..3e580a0fb 100644
--- a/src/rpc/core_rpc_server.cpp
+++ b/src/rpc/core_rpc_server.cpp
@@ -247,7 +247,6 @@ namespace cryptonote
res.cumulative_difficulty, res.wide_cumulative_difficulty, res.cumulative_difficulty_top64);
res.block_size_limit = res.block_weight_limit = m_core.get_blockchain_storage().get_current_cumulative_block_weight_limit();
res.block_size_median = res.block_weight_median = m_core.get_blockchain_storage().get_current_cumulative_block_weight_median();
- res.status = CORE_RPC_STATUS_OK;
res.start_time = restricted ? 0 : (uint64_t)m_core.get_start_time();
res.free_space = restricted ? std::numeric_limits<uint64_t>::max() : m_core.get_free_space();
res.offline = m_core.offline();
@@ -265,6 +264,8 @@ namespace cryptonote
res.database_size = round_up(res.database_size, 5ull* 1024 * 1024 * 1024);
res.update_available = restricted ? false : m_core.is_update_available();
res.version = restricted ? "" : MONERO_VERSION;
+
+ res.status = CORE_RPC_STATUS_OK;
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
@@ -1749,67 +1750,7 @@ namespace cryptonote
//------------------------------------------------------------------------------------------------------------------------------
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, const connection_context *ctx)
{
- PERF_TIMER(on_get_info_json);
- bool r;
- if (use_bootstrap_daemon_if_necessary<COMMAND_RPC_GET_INFO>(invoke_http_mode::JON_RPC, "get_info", req, res, r))
- {
- res.bootstrap_daemon_address = m_bootstrap_daemon_address;
- crypto::hash top_hash;
- m_core.get_blockchain_top(res.height_without_bootstrap, top_hash);
- ++res.height_without_bootstrap; // turn top block height into blockchain height
- res.was_bootstrap_ever_used = true;
- return r;
- }
-
- const bool restricted = m_restricted && ctx;
-
- crypto::hash top_hash;
- m_core.get_blockchain_top(res.height, top_hash);
- ++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();
- store_difficulty(m_core.get_blockchain_storage().get_difficulty_for_next_block(),
- res.difficulty, res.wide_difficulty, res.difficulty_top64);
- res.target = m_core.get_blockchain_storage().get_current_hard_fork_version() < 2 ? DIFFICULTY_TARGET_V1 : DIFFICULTY_TARGET_V2;
- 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 = restricted ? 0 : m_core.get_blockchain_storage().get_alternative_blocks_count();
- uint64_t total_conn = restricted ? 0 : m_p2p.get_public_connections_count();
- res.outgoing_connections_count = restricted ? 0 : m_p2p.get_public_outgoing_connections_count();
- res.incoming_connections_count = restricted ? 0 : (total_conn - res.outgoing_connections_count);
- res.rpc_connections_count = restricted ? 0 : get_connections_count();
- res.white_peerlist_size = restricted ? 0 : m_p2p.get_public_white_peers_count();
- res.grey_peerlist_size = restricted ? 0 : m_p2p.get_public_gray_peers_count();
-
- cryptonote::network_type net_type = nettype();
- res.mainnet = net_type == MAINNET;
- res.testnet = net_type == TESTNET;
- res.stagenet = net_type == STAGENET;
- res.nettype = net_type == MAINNET ? "mainnet" : net_type == TESTNET ? "testnet" : net_type == STAGENET ? "stagenet" : "fakechain";
-
- store_difficulty(m_core.get_blockchain_storage().get_db().get_block_cumulative_difficulty(res.height - 1),
- res.cumulative_difficulty, res.wide_cumulative_difficulty, res.cumulative_difficulty_top64);
- res.block_size_limit = res.block_weight_limit = m_core.get_blockchain_storage().get_current_cumulative_block_weight_limit();
- res.block_size_median = res.block_weight_median = m_core.get_blockchain_storage().get_current_cumulative_block_weight_median();
- res.status = CORE_RPC_STATUS_OK;
- res.start_time = restricted ? 0 : (uint64_t)m_core.get_start_time();
- res.free_space = restricted ? std::numeric_limits<uint64_t>::max() : m_core.get_free_space();
- res.offline = m_core.offline();
- res.bootstrap_daemon_address = restricted ? "" : m_bootstrap_daemon_address;
- res.height_without_bootstrap = restricted ? 0 : res.height;
- if (restricted)
- res.was_bootstrap_ever_used = false;
- else
- {
- boost::shared_lock<boost::shared_mutex> lock(m_bootstrap_daemon_mutex);
- res.was_bootstrap_ever_used = m_was_bootstrap_ever_used;
- }
- res.database_size = m_core.get_blockchain_storage().get_db().get_database_size();
- if (restricted)
- res.database_size = round_up(res.database_size, 5ull * 1024 * 1024 * 1024);
- res.update_available = restricted ? false : m_core.is_update_available();
- res.version = restricted ? "" : MONERO_VERSION;
- return true;
+ return on_get_info(req, res, ctx);
}
//------------------------------------------------------------------------------------------------------------------------------
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, const connection_context *ctx)