mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2024-11-29 18:53:14 +00:00
rpc: merge the two get_info implementations
This commit is contained in:
parent
3759e2359f
commit
e8cf7dcc2b
1 changed files with 3 additions and 62 deletions
|
@ -247,7 +247,6 @@ namespace cryptonote
|
||||||
res.cumulative_difficulty, res.wide_cumulative_difficulty, res.cumulative_difficulty_top64);
|
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_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.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.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.free_space = restricted ? std::numeric_limits<uint64_t>::max() : m_core.get_free_space();
|
||||||
res.offline = m_core.offline();
|
res.offline = m_core.offline();
|
||||||
|
@ -265,6 +264,8 @@ namespace cryptonote
|
||||||
res.database_size = round_up(res.database_size, 5ull* 1024 * 1024 * 1024);
|
res.database_size = round_up(res.database_size, 5ull* 1024 * 1024 * 1024);
|
||||||
res.update_available = restricted ? false : m_core.is_update_available();
|
res.update_available = restricted ? false : m_core.is_update_available();
|
||||||
res.version = restricted ? "" : MONERO_VERSION;
|
res.version = restricted ? "" : MONERO_VERSION;
|
||||||
|
|
||||||
|
res.status = CORE_RPC_STATUS_OK;
|
||||||
return true;
|
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)
|
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);
|
return on_get_info(req, res, ctx);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------------------------------------
|
||||||
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)
|
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)
|
||||||
|
|
Loading…
Reference in a new issue