|
|
@ -147,7 +147,7 @@ namespace cryptonote
|
|
|
|
#define CHECK_CORE_READY() do { if(!check_core_ready()){res.status = CORE_RPC_STATUS_BUSY;return true;} } while(0)
|
|
|
|
#define CHECK_CORE_READY() do { if(!check_core_ready()){res.status = CORE_RPC_STATUS_BUSY;return true;} } while(0)
|
|
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool core_rpc_server::on_get_height(const COMMAND_RPC_GET_HEIGHT::request& req, COMMAND_RPC_GET_HEIGHT::response& res)
|
|
|
|
bool core_rpc_server::on_get_height(const COMMAND_RPC_GET_HEIGHT::request& req, COMMAND_RPC_GET_HEIGHT::response& res, const connection_context *ctx)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PERF_TIMER(on_get_height);
|
|
|
|
PERF_TIMER(on_get_height);
|
|
|
|
bool r;
|
|
|
|
bool r;
|
|
|
@ -159,7 +159,7 @@ namespace cryptonote
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool core_rpc_server::on_get_info(const COMMAND_RPC_GET_INFO::request& req, COMMAND_RPC_GET_INFO::response& res)
|
|
|
|
bool core_rpc_server::on_get_info(const COMMAND_RPC_GET_INFO::request& req, COMMAND_RPC_GET_INFO::response& res, const connection_context *ctx)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PERF_TIMER(on_get_info);
|
|
|
|
PERF_TIMER(on_get_info);
|
|
|
|
bool r;
|
|
|
|
bool r;
|
|
|
@ -173,6 +173,8 @@ namespace cryptonote
|
|
|
|
return r;
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const bool restricted = m_restricted && ctx;
|
|
|
|
|
|
|
|
|
|
|
|
crypto::hash top_hash;
|
|
|
|
crypto::hash top_hash;
|
|
|
|
m_core.get_blockchain_top(res.height, top_hash);
|
|
|
|
m_core.get_blockchain_top(res.height, top_hash);
|
|
|
|
++res.height; // turn top block height into blockchain height
|
|
|
|
++res.height; // turn top block height into blockchain height
|
|
|
@ -182,13 +184,13 @@ namespace cryptonote
|
|
|
|
res.target = m_core.get_blockchain_storage().get_difficulty_target();
|
|
|
|
res.target = m_core.get_blockchain_storage().get_difficulty_target();
|
|
|
|
res.tx_count = m_core.get_blockchain_storage().get_total_transactions() - res.height; //without coinbase
|
|
|
|
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.tx_pool_size = m_core.get_pool_transactions_count();
|
|
|
|
res.alt_blocks_count = m_restricted ? 0 : m_core.get_blockchain_storage().get_alternative_blocks_count();
|
|
|
|
res.alt_blocks_count = restricted ? 0 : m_core.get_blockchain_storage().get_alternative_blocks_count();
|
|
|
|
uint64_t total_conn = m_restricted ? 0 : m_p2p.get_connections_count();
|
|
|
|
uint64_t total_conn = restricted ? 0 : m_p2p.get_connections_count();
|
|
|
|
res.outgoing_connections_count = m_restricted ? 0 : m_p2p.get_outgoing_connections_count();
|
|
|
|
res.outgoing_connections_count = restricted ? 0 : m_p2p.get_outgoing_connections_count();
|
|
|
|
res.incoming_connections_count = m_restricted ? 0 : (total_conn - res.outgoing_connections_count);
|
|
|
|
res.incoming_connections_count = restricted ? 0 : (total_conn - res.outgoing_connections_count);
|
|
|
|
res.rpc_connections_count = m_restricted ? 0 : get_connections_count();
|
|
|
|
res.rpc_connections_count = restricted ? 0 : get_connections_count();
|
|
|
|
res.white_peerlist_size = m_restricted ? 0 : m_p2p.get_peerlist_manager().get_white_peers_count();
|
|
|
|
res.white_peerlist_size = restricted ? 0 : m_p2p.get_peerlist_manager().get_white_peers_count();
|
|
|
|
res.grey_peerlist_size = m_restricted ? 0 : m_p2p.get_peerlist_manager().get_gray_peers_count();
|
|
|
|
res.grey_peerlist_size = restricted ? 0 : m_p2p.get_peerlist_manager().get_gray_peers_count();
|
|
|
|
|
|
|
|
|
|
|
|
cryptonote::network_type net_type = nettype();
|
|
|
|
cryptonote::network_type net_type = nettype();
|
|
|
|
res.mainnet = net_type == MAINNET;
|
|
|
|
res.mainnet = net_type == MAINNET;
|
|
|
@ -199,21 +201,21 @@ namespace cryptonote
|
|
|
|
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.status = CORE_RPC_STATUS_OK;
|
|
|
|
res.start_time = m_restricted ? 0 : (uint64_t)m_core.get_start_time();
|
|
|
|
res.start_time = restricted ? 0 : (uint64_t)m_core.get_start_time();
|
|
|
|
res.free_space = m_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();
|
|
|
|
res.bootstrap_daemon_address = m_restricted ? "" : m_bootstrap_daemon_address;
|
|
|
|
res.bootstrap_daemon_address = restricted ? "" : m_bootstrap_daemon_address;
|
|
|
|
res.height_without_bootstrap = m_restricted ? 0 : res.height;
|
|
|
|
res.height_without_bootstrap = restricted ? 0 : res.height;
|
|
|
|
if (m_restricted)
|
|
|
|
if (restricted)
|
|
|
|
res.was_bootstrap_ever_used = false;
|
|
|
|
res.was_bootstrap_ever_used = false;
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
boost::shared_lock<boost::shared_mutex> lock(m_bootstrap_daemon_mutex);
|
|
|
|
boost::shared_lock<boost::shared_mutex> lock(m_bootstrap_daemon_mutex);
|
|
|
|
res.was_bootstrap_ever_used = m_was_bootstrap_ever_used;
|
|
|
|
res.was_bootstrap_ever_used = m_was_bootstrap_ever_used;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
res.database_size = m_restricted ? 0 : m_core.get_blockchain_storage().get_db().get_database_size();
|
|
|
|
res.database_size = restricted ? 0 : m_core.get_blockchain_storage().get_db().get_database_size();
|
|
|
|
res.update_available = m_restricted ? false : m_core.is_update_available();
|
|
|
|
res.update_available = restricted ? false : m_core.is_update_available();
|
|
|
|
res.version = m_restricted ? "" : MONERO_VERSION;
|
|
|
|
res.version = restricted ? "" : MONERO_VERSION;
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
@ -227,7 +229,7 @@ namespace cryptonote
|
|
|
|
END_SERIALIZE()
|
|
|
|
END_SERIALIZE()
|
|
|
|
};
|
|
|
|
};
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool core_rpc_server::on_get_blocks(const COMMAND_RPC_GET_BLOCKS_FAST::request& req, COMMAND_RPC_GET_BLOCKS_FAST::response& res)
|
|
|
|
bool core_rpc_server::on_get_blocks(const COMMAND_RPC_GET_BLOCKS_FAST::request& req, COMMAND_RPC_GET_BLOCKS_FAST::response& res, const connection_context *ctx)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PERF_TIMER(on_get_blocks);
|
|
|
|
PERF_TIMER(on_get_blocks);
|
|
|
|
bool r;
|
|
|
|
bool r;
|
|
|
@ -290,7 +292,7 @@ namespace cryptonote
|
|
|
|
res.status = CORE_RPC_STATUS_OK;
|
|
|
|
res.status = CORE_RPC_STATUS_OK;
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bool core_rpc_server::on_get_alt_blocks_hashes(const COMMAND_RPC_GET_ALT_BLOCKS_HASHES::request& req, COMMAND_RPC_GET_ALT_BLOCKS_HASHES::response& res)
|
|
|
|
bool core_rpc_server::on_get_alt_blocks_hashes(const COMMAND_RPC_GET_ALT_BLOCKS_HASHES::request& req, COMMAND_RPC_GET_ALT_BLOCKS_HASHES::response& res, const connection_context *ctx)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PERF_TIMER(on_get_alt_blocks_hashes);
|
|
|
|
PERF_TIMER(on_get_alt_blocks_hashes);
|
|
|
|
bool r;
|
|
|
|
bool r;
|
|
|
@ -317,7 +319,7 @@ namespace cryptonote
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool core_rpc_server::on_get_blocks_by_height(const COMMAND_RPC_GET_BLOCKS_BY_HEIGHT::request& req, COMMAND_RPC_GET_BLOCKS_BY_HEIGHT::response& res)
|
|
|
|
bool core_rpc_server::on_get_blocks_by_height(const COMMAND_RPC_GET_BLOCKS_BY_HEIGHT::request& req, COMMAND_RPC_GET_BLOCKS_BY_HEIGHT::response& res, const connection_context *ctx)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PERF_TIMER(on_get_blocks_by_height);
|
|
|
|
PERF_TIMER(on_get_blocks_by_height);
|
|
|
|
bool r;
|
|
|
|
bool r;
|
|
|
@ -351,7 +353,7 @@ namespace cryptonote
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool core_rpc_server::on_get_hashes(const COMMAND_RPC_GET_HASHES_FAST::request& req, COMMAND_RPC_GET_HASHES_FAST::response& res)
|
|
|
|
bool core_rpc_server::on_get_hashes(const COMMAND_RPC_GET_HASHES_FAST::request& req, COMMAND_RPC_GET_HASHES_FAST::response& res, const connection_context *ctx)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PERF_TIMER(on_get_hashes);
|
|
|
|
PERF_TIMER(on_get_hashes);
|
|
|
|
bool r;
|
|
|
|
bool r;
|
|
|
@ -374,7 +376,7 @@ namespace cryptonote
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool core_rpc_server::on_get_outs_bin(const COMMAND_RPC_GET_OUTPUTS_BIN::request& req, COMMAND_RPC_GET_OUTPUTS_BIN::response& res)
|
|
|
|
bool core_rpc_server::on_get_outs_bin(const COMMAND_RPC_GET_OUTPUTS_BIN::request& req, COMMAND_RPC_GET_OUTPUTS_BIN::response& res, const connection_context *ctx)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PERF_TIMER(on_get_outs_bin);
|
|
|
|
PERF_TIMER(on_get_outs_bin);
|
|
|
|
bool r;
|
|
|
|
bool r;
|
|
|
@ -383,7 +385,8 @@ namespace cryptonote
|
|
|
|
|
|
|
|
|
|
|
|
res.status = "Failed";
|
|
|
|
res.status = "Failed";
|
|
|
|
|
|
|
|
|
|
|
|
if (m_restricted)
|
|
|
|
const bool restricted = m_restricted && ctx;
|
|
|
|
|
|
|
|
if (restricted)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (req.outputs.size() > MAX_RESTRICTED_GLOBAL_FAKE_OUTS_COUNT)
|
|
|
|
if (req.outputs.size() > MAX_RESTRICTED_GLOBAL_FAKE_OUTS_COUNT)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -401,7 +404,7 @@ namespace cryptonote
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool core_rpc_server::on_get_outs(const COMMAND_RPC_GET_OUTPUTS::request& req, COMMAND_RPC_GET_OUTPUTS::response& res)
|
|
|
|
bool core_rpc_server::on_get_outs(const COMMAND_RPC_GET_OUTPUTS::request& req, COMMAND_RPC_GET_OUTPUTS::response& res, const connection_context *ctx)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PERF_TIMER(on_get_outs);
|
|
|
|
PERF_TIMER(on_get_outs);
|
|
|
|
bool r;
|
|
|
|
bool r;
|
|
|
@ -410,7 +413,8 @@ namespace cryptonote
|
|
|
|
|
|
|
|
|
|
|
|
res.status = "Failed";
|
|
|
|
res.status = "Failed";
|
|
|
|
|
|
|
|
|
|
|
|
if (m_restricted)
|
|
|
|
const bool restricted = m_restricted && ctx;
|
|
|
|
|
|
|
|
if (restricted)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (req.outputs.size() > MAX_RESTRICTED_GLOBAL_FAKE_OUTS_COUNT)
|
|
|
|
if (req.outputs.size() > MAX_RESTRICTED_GLOBAL_FAKE_OUTS_COUNT)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -443,7 +447,7 @@ namespace cryptonote
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool core_rpc_server::on_get_indexes(const COMMAND_RPC_GET_TX_GLOBAL_OUTPUTS_INDEXES::request& req, COMMAND_RPC_GET_TX_GLOBAL_OUTPUTS_INDEXES::response& res)
|
|
|
|
bool core_rpc_server::on_get_indexes(const COMMAND_RPC_GET_TX_GLOBAL_OUTPUTS_INDEXES::request& req, COMMAND_RPC_GET_TX_GLOBAL_OUTPUTS_INDEXES::response& res, const connection_context *ctx)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PERF_TIMER(on_get_indexes);
|
|
|
|
PERF_TIMER(on_get_indexes);
|
|
|
|
bool ok;
|
|
|
|
bool ok;
|
|
|
@ -461,7 +465,7 @@ namespace cryptonote
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool core_rpc_server::on_get_transactions(const COMMAND_RPC_GET_TRANSACTIONS::request& req, COMMAND_RPC_GET_TRANSACTIONS::response& res)
|
|
|
|
bool core_rpc_server::on_get_transactions(const COMMAND_RPC_GET_TRANSACTIONS::request& req, COMMAND_RPC_GET_TRANSACTIONS::response& res, const connection_context *ctx)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PERF_TIMER(on_get_transactions);
|
|
|
|
PERF_TIMER(on_get_transactions);
|
|
|
|
bool ok;
|
|
|
|
bool ok;
|
|
|
@ -617,13 +621,15 @@ namespace cryptonote
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool core_rpc_server::on_is_key_image_spent(const COMMAND_RPC_IS_KEY_IMAGE_SPENT::request& req, COMMAND_RPC_IS_KEY_IMAGE_SPENT::response& res, bool request_has_rpc_origin)
|
|
|
|
bool core_rpc_server::on_is_key_image_spent(const COMMAND_RPC_IS_KEY_IMAGE_SPENT::request& req, COMMAND_RPC_IS_KEY_IMAGE_SPENT::response& res, const connection_context *ctx)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PERF_TIMER(on_is_key_image_spent);
|
|
|
|
PERF_TIMER(on_is_key_image_spent);
|
|
|
|
bool ok;
|
|
|
|
bool ok;
|
|
|
|
if (use_bootstrap_daemon_if_necessary<COMMAND_RPC_IS_KEY_IMAGE_SPENT>(invoke_http_mode::JON, "/is_key_image_spent", req, res, ok))
|
|
|
|
if (use_bootstrap_daemon_if_necessary<COMMAND_RPC_IS_KEY_IMAGE_SPENT>(invoke_http_mode::JON, "/is_key_image_spent", req, res, ok))
|
|
|
|
return ok;
|
|
|
|
return ok;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const bool restricted = m_restricted && ctx;
|
|
|
|
|
|
|
|
const bool request_has_rpc_origin = ctx != NULL;
|
|
|
|
std::vector<crypto::key_image> key_images;
|
|
|
|
std::vector<crypto::key_image> key_images;
|
|
|
|
for(const auto& ki_hex_str: req.key_images)
|
|
|
|
for(const auto& ki_hex_str: req.key_images)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -653,7 +659,7 @@ namespace cryptonote
|
|
|
|
// check the pool too
|
|
|
|
// check the pool too
|
|
|
|
std::vector<cryptonote::tx_info> txs;
|
|
|
|
std::vector<cryptonote::tx_info> txs;
|
|
|
|
std::vector<cryptonote::spent_key_image_info> ki;
|
|
|
|
std::vector<cryptonote::spent_key_image_info> ki;
|
|
|
|
r = m_core.get_pool_transactions_and_spent_keys_info(txs, ki, !request_has_rpc_origin || !m_restricted);
|
|
|
|
r = m_core.get_pool_transactions_and_spent_keys_info(txs, ki, !request_has_rpc_origin || !restricted);
|
|
|
|
if(!r)
|
|
|
|
if(!r)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
res.status = "Failed";
|
|
|
|
res.status = "Failed";
|
|
|
@ -684,7 +690,7 @@ namespace cryptonote
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool core_rpc_server::on_send_raw_tx(const COMMAND_RPC_SEND_RAW_TX::request& req, COMMAND_RPC_SEND_RAW_TX::response& res)
|
|
|
|
bool core_rpc_server::on_send_raw_tx(const COMMAND_RPC_SEND_RAW_TX::request& req, COMMAND_RPC_SEND_RAW_TX::response& res, const connection_context *ctx)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PERF_TIMER(on_send_raw_tx);
|
|
|
|
PERF_TIMER(on_send_raw_tx);
|
|
|
|
bool ok;
|
|
|
|
bool ok;
|
|
|
@ -752,7 +758,7 @@ namespace cryptonote
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool core_rpc_server::on_start_mining(const COMMAND_RPC_START_MINING::request& req, COMMAND_RPC_START_MINING::response& res)
|
|
|
|
bool core_rpc_server::on_start_mining(const COMMAND_RPC_START_MINING::request& req, COMMAND_RPC_START_MINING::response& res, const connection_context *ctx)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PERF_TIMER(on_start_mining);
|
|
|
|
PERF_TIMER(on_start_mining);
|
|
|
|
CHECK_CORE_READY();
|
|
|
|
CHECK_CORE_READY();
|
|
|
@ -806,7 +812,7 @@ namespace cryptonote
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool core_rpc_server::on_stop_mining(const COMMAND_RPC_STOP_MINING::request& req, COMMAND_RPC_STOP_MINING::response& res)
|
|
|
|
bool core_rpc_server::on_stop_mining(const COMMAND_RPC_STOP_MINING::request& req, COMMAND_RPC_STOP_MINING::response& res, const connection_context *ctx)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PERF_TIMER(on_stop_mining);
|
|
|
|
PERF_TIMER(on_stop_mining);
|
|
|
|
cryptonote::miner &miner= m_core.get_miner();
|
|
|
|
cryptonote::miner &miner= m_core.get_miner();
|
|
|
@ -826,7 +832,7 @@ namespace cryptonote
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool core_rpc_server::on_mining_status(const COMMAND_RPC_MINING_STATUS::request& req, COMMAND_RPC_MINING_STATUS::response& res)
|
|
|
|
bool core_rpc_server::on_mining_status(const COMMAND_RPC_MINING_STATUS::request& req, COMMAND_RPC_MINING_STATUS::response& res, const connection_context *ctx)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PERF_TIMER(on_mining_status);
|
|
|
|
PERF_TIMER(on_mining_status);
|
|
|
|
|
|
|
|
|
|
|
@ -845,7 +851,7 @@ namespace cryptonote
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool core_rpc_server::on_save_bc(const COMMAND_RPC_SAVE_BC::request& req, COMMAND_RPC_SAVE_BC::response& res)
|
|
|
|
bool core_rpc_server::on_save_bc(const COMMAND_RPC_SAVE_BC::request& req, COMMAND_RPC_SAVE_BC::response& res, const connection_context *ctx)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PERF_TIMER(on_save_bc);
|
|
|
|
PERF_TIMER(on_save_bc);
|
|
|
|
if( !m_core.get_blockchain_storage().store_blockchain() )
|
|
|
|
if( !m_core.get_blockchain_storage().store_blockchain() )
|
|
|
@ -857,7 +863,7 @@ namespace cryptonote
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool core_rpc_server::on_get_peer_list(const COMMAND_RPC_GET_PEER_LIST::request& req, COMMAND_RPC_GET_PEER_LIST::response& res)
|
|
|
|
bool core_rpc_server::on_get_peer_list(const COMMAND_RPC_GET_PEER_LIST::request& req, COMMAND_RPC_GET_PEER_LIST::response& res, const connection_context *ctx)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PERF_TIMER(on_get_peer_list);
|
|
|
|
PERF_TIMER(on_get_peer_list);
|
|
|
|
std::vector<nodetool::peerlist_entry> white_list;
|
|
|
|
std::vector<nodetool::peerlist_entry> white_list;
|
|
|
@ -888,7 +894,7 @@ namespace cryptonote
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool core_rpc_server::on_set_log_hash_rate(const COMMAND_RPC_SET_LOG_HASH_RATE::request& req, COMMAND_RPC_SET_LOG_HASH_RATE::response& res)
|
|
|
|
bool core_rpc_server::on_set_log_hash_rate(const COMMAND_RPC_SET_LOG_HASH_RATE::request& req, COMMAND_RPC_SET_LOG_HASH_RATE::response& res, const connection_context *ctx)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PERF_TIMER(on_set_log_hash_rate);
|
|
|
|
PERF_TIMER(on_set_log_hash_rate);
|
|
|
|
if(m_core.get_miner().is_mining())
|
|
|
|
if(m_core.get_miner().is_mining())
|
|
|
@ -903,7 +909,7 @@ namespace cryptonote
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool core_rpc_server::on_set_log_level(const COMMAND_RPC_SET_LOG_LEVEL::request& req, COMMAND_RPC_SET_LOG_LEVEL::response& res)
|
|
|
|
bool core_rpc_server::on_set_log_level(const COMMAND_RPC_SET_LOG_LEVEL::request& req, COMMAND_RPC_SET_LOG_LEVEL::response& res, const connection_context *ctx)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PERF_TIMER(on_set_log_level);
|
|
|
|
PERF_TIMER(on_set_log_level);
|
|
|
|
if (req.level < 0 || req.level > 4)
|
|
|
|
if (req.level < 0 || req.level > 4)
|
|
|
@ -916,7 +922,7 @@ namespace cryptonote
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool core_rpc_server::on_set_log_categories(const COMMAND_RPC_SET_LOG_CATEGORIES::request& req, COMMAND_RPC_SET_LOG_CATEGORIES::response& res)
|
|
|
|
bool core_rpc_server::on_set_log_categories(const COMMAND_RPC_SET_LOG_CATEGORIES::request& req, COMMAND_RPC_SET_LOG_CATEGORIES::response& res, const connection_context *ctx)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PERF_TIMER(on_set_log_categories);
|
|
|
|
PERF_TIMER(on_set_log_categories);
|
|
|
|
mlog_set_log(req.categories.c_str());
|
|
|
|
mlog_set_log(req.categories.c_str());
|
|
|
@ -925,41 +931,47 @@ namespace cryptonote
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool core_rpc_server::on_get_transaction_pool(const COMMAND_RPC_GET_TRANSACTION_POOL::request& req, COMMAND_RPC_GET_TRANSACTION_POOL::response& res, bool request_has_rpc_origin)
|
|
|
|
bool core_rpc_server::on_get_transaction_pool(const COMMAND_RPC_GET_TRANSACTION_POOL::request& req, COMMAND_RPC_GET_TRANSACTION_POOL::response& res, const connection_context *ctx)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PERF_TIMER(on_get_transaction_pool);
|
|
|
|
PERF_TIMER(on_get_transaction_pool);
|
|
|
|
bool r;
|
|
|
|
bool r;
|
|
|
|
if (use_bootstrap_daemon_if_necessary<COMMAND_RPC_GET_TRANSACTION_POOL>(invoke_http_mode::JON, "/get_transaction_pool", req, res, r))
|
|
|
|
if (use_bootstrap_daemon_if_necessary<COMMAND_RPC_GET_TRANSACTION_POOL>(invoke_http_mode::JON, "/get_transaction_pool", req, res, r))
|
|
|
|
return r;
|
|
|
|
return r;
|
|
|
|
|
|
|
|
|
|
|
|
m_core.get_pool_transactions_and_spent_keys_info(res.transactions, res.spent_key_images, !request_has_rpc_origin || !m_restricted);
|
|
|
|
const bool restricted = m_restricted && ctx;
|
|
|
|
|
|
|
|
const bool request_has_rpc_origin = ctx != NULL;
|
|
|
|
|
|
|
|
m_core.get_pool_transactions_and_spent_keys_info(res.transactions, res.spent_key_images, !request_has_rpc_origin || !restricted);
|
|
|
|
for (tx_info& txi : res.transactions)
|
|
|
|
for (tx_info& txi : res.transactions)
|
|
|
|
txi.tx_blob = epee::string_tools::buff_to_hex_nodelimer(txi.tx_blob);
|
|
|
|
txi.tx_blob = epee::string_tools::buff_to_hex_nodelimer(txi.tx_blob);
|
|
|
|
res.status = CORE_RPC_STATUS_OK;
|
|
|
|
res.status = CORE_RPC_STATUS_OK;
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool core_rpc_server::on_get_transaction_pool_hashes_bin(const COMMAND_RPC_GET_TRANSACTION_POOL_HASHES_BIN::request& req, COMMAND_RPC_GET_TRANSACTION_POOL_HASHES_BIN::response& res, bool request_has_rpc_origin)
|
|
|
|
bool core_rpc_server::on_get_transaction_pool_hashes_bin(const COMMAND_RPC_GET_TRANSACTION_POOL_HASHES_BIN::request& req, COMMAND_RPC_GET_TRANSACTION_POOL_HASHES_BIN::response& res, const connection_context *ctx)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PERF_TIMER(on_get_transaction_pool_hashes);
|
|
|
|
PERF_TIMER(on_get_transaction_pool_hashes);
|
|
|
|
bool r;
|
|
|
|
bool r;
|
|
|
|
if (use_bootstrap_daemon_if_necessary<COMMAND_RPC_GET_TRANSACTION_POOL_HASHES_BIN>(invoke_http_mode::JON, "/get_transaction_pool_hashes.bin", req, res, r))
|
|
|
|
if (use_bootstrap_daemon_if_necessary<COMMAND_RPC_GET_TRANSACTION_POOL_HASHES_BIN>(invoke_http_mode::JON, "/get_transaction_pool_hashes.bin", req, res, r))
|
|
|
|
return r;
|
|
|
|
return r;
|
|
|
|
|
|
|
|
|
|
|
|
m_core.get_pool_transaction_hashes(res.tx_hashes, !request_has_rpc_origin || !m_restricted);
|
|
|
|
const bool restricted = m_restricted && ctx;
|
|
|
|
|
|
|
|
const bool request_has_rpc_origin = ctx != NULL;
|
|
|
|
|
|
|
|
m_core.get_pool_transaction_hashes(res.tx_hashes, !request_has_rpc_origin || !restricted);
|
|
|
|
res.status = CORE_RPC_STATUS_OK;
|
|
|
|
res.status = CORE_RPC_STATUS_OK;
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool core_rpc_server::on_get_transaction_pool_hashes(const COMMAND_RPC_GET_TRANSACTION_POOL_HASHES::request& req, COMMAND_RPC_GET_TRANSACTION_POOL_HASHES::response& res, bool request_has_rpc_origin)
|
|
|
|
bool core_rpc_server::on_get_transaction_pool_hashes(const COMMAND_RPC_GET_TRANSACTION_POOL_HASHES::request& req, COMMAND_RPC_GET_TRANSACTION_POOL_HASHES::response& res, const connection_context *ctx)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PERF_TIMER(on_get_transaction_pool_hashes);
|
|
|
|
PERF_TIMER(on_get_transaction_pool_hashes);
|
|
|
|
bool r;
|
|
|
|
bool r;
|
|
|
|
if (use_bootstrap_daemon_if_necessary<COMMAND_RPC_GET_TRANSACTION_POOL_HASHES>(invoke_http_mode::JON, "/get_transaction_pool_hashes", req, res, r))
|
|
|
|
if (use_bootstrap_daemon_if_necessary<COMMAND_RPC_GET_TRANSACTION_POOL_HASHES>(invoke_http_mode::JON, "/get_transaction_pool_hashes", req, res, r))
|
|
|
|
return r;
|
|
|
|
return r;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const bool restricted = m_restricted && ctx;
|
|
|
|
|
|
|
|
const bool request_has_rpc_origin = ctx != NULL;
|
|
|
|
std::vector<crypto::hash> tx_hashes;
|
|
|
|
std::vector<crypto::hash> tx_hashes;
|
|
|
|
m_core.get_pool_transaction_hashes(tx_hashes, !request_has_rpc_origin || !m_restricted);
|
|
|
|
m_core.get_pool_transaction_hashes(tx_hashes, !request_has_rpc_origin || !restricted);
|
|
|
|
res.tx_hashes.reserve(tx_hashes.size());
|
|
|
|
res.tx_hashes.reserve(tx_hashes.size());
|
|
|
|
for (const crypto::hash &tx_hash: tx_hashes)
|
|
|
|
for (const crypto::hash &tx_hash: tx_hashes)
|
|
|
|
res.tx_hashes.push_back(epee::string_tools::pod_to_hex(tx_hash));
|
|
|
|
res.tx_hashes.push_back(epee::string_tools::pod_to_hex(tx_hash));
|
|
|
@ -967,19 +979,21 @@ namespace cryptonote
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool core_rpc_server::on_get_transaction_pool_stats(const COMMAND_RPC_GET_TRANSACTION_POOL_STATS::request& req, COMMAND_RPC_GET_TRANSACTION_POOL_STATS::response& res, bool request_has_rpc_origin)
|
|
|
|
bool core_rpc_server::on_get_transaction_pool_stats(const COMMAND_RPC_GET_TRANSACTION_POOL_STATS::request& req, COMMAND_RPC_GET_TRANSACTION_POOL_STATS::response& res, const connection_context *ctx)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PERF_TIMER(on_get_transaction_pool_stats);
|
|
|
|
PERF_TIMER(on_get_transaction_pool_stats);
|
|
|
|
bool r;
|
|
|
|
bool r;
|
|
|
|
if (use_bootstrap_daemon_if_necessary<COMMAND_RPC_GET_TRANSACTION_POOL_STATS>(invoke_http_mode::JON, "/get_transaction_pool_stats", req, res, r))
|
|
|
|
if (use_bootstrap_daemon_if_necessary<COMMAND_RPC_GET_TRANSACTION_POOL_STATS>(invoke_http_mode::JON, "/get_transaction_pool_stats", req, res, r))
|
|
|
|
return r;
|
|
|
|
return r;
|
|
|
|
|
|
|
|
|
|
|
|
m_core.get_pool_transaction_stats(res.pool_stats, !request_has_rpc_origin || !m_restricted);
|
|
|
|
const bool restricted = m_restricted && ctx;
|
|
|
|
|
|
|
|
const bool request_has_rpc_origin = ctx != NULL;
|
|
|
|
|
|
|
|
m_core.get_pool_transaction_stats(res.pool_stats, !request_has_rpc_origin || !restricted);
|
|
|
|
res.status = CORE_RPC_STATUS_OK;
|
|
|
|
res.status = CORE_RPC_STATUS_OK;
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool core_rpc_server::on_stop_daemon(const COMMAND_RPC_STOP_DAEMON::request& req, COMMAND_RPC_STOP_DAEMON::response& res)
|
|
|
|
bool core_rpc_server::on_stop_daemon(const COMMAND_RPC_STOP_DAEMON::request& req, COMMAND_RPC_STOP_DAEMON::response& res, const connection_context *ctx)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PERF_TIMER(on_stop_daemon);
|
|
|
|
PERF_TIMER(on_stop_daemon);
|
|
|
|
// FIXME: replace back to original m_p2p.send_stop_signal() after
|
|
|
|
// FIXME: replace back to original m_p2p.send_stop_signal() after
|
|
|
@ -989,7 +1003,7 @@ namespace cryptonote
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool core_rpc_server::on_getblockcount(const COMMAND_RPC_GETBLOCKCOUNT::request& req, COMMAND_RPC_GETBLOCKCOUNT::response& res)
|
|
|
|
bool core_rpc_server::on_getblockcount(const COMMAND_RPC_GETBLOCKCOUNT::request& req, COMMAND_RPC_GETBLOCKCOUNT::response& res, const connection_context *ctx)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PERF_TIMER(on_getblockcount);
|
|
|
|
PERF_TIMER(on_getblockcount);
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -1005,7 +1019,7 @@ namespace cryptonote
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool core_rpc_server::on_getblockhash(const COMMAND_RPC_GETBLOCKHASH::request& req, COMMAND_RPC_GETBLOCKHASH::response& res, epee::json_rpc::error& error_resp)
|
|
|
|
bool core_rpc_server::on_getblockhash(const COMMAND_RPC_GETBLOCKHASH::request& req, COMMAND_RPC_GETBLOCKHASH::response& res, epee::json_rpc::error& error_resp, const connection_context *ctx)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PERF_TIMER(on_getblockhash);
|
|
|
|
PERF_TIMER(on_getblockhash);
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -1049,7 +1063,7 @@ namespace cryptonote
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool core_rpc_server::on_getblocktemplate(const COMMAND_RPC_GETBLOCKTEMPLATE::request& req, COMMAND_RPC_GETBLOCKTEMPLATE::response& res, epee::json_rpc::error& error_resp)
|
|
|
|
bool core_rpc_server::on_getblocktemplate(const COMMAND_RPC_GETBLOCKTEMPLATE::request& req, COMMAND_RPC_GETBLOCKTEMPLATE::response& res, epee::json_rpc::error& error_resp, const connection_context *ctx)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PERF_TIMER(on_getblocktemplate);
|
|
|
|
PERF_TIMER(on_getblocktemplate);
|
|
|
|
bool r;
|
|
|
|
bool r;
|
|
|
@ -1128,7 +1142,7 @@ namespace cryptonote
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool core_rpc_server::on_submitblock(const COMMAND_RPC_SUBMITBLOCK::request& req, COMMAND_RPC_SUBMITBLOCK::response& res, epee::json_rpc::error& error_resp)
|
|
|
|
bool core_rpc_server::on_submitblock(const COMMAND_RPC_SUBMITBLOCK::request& req, COMMAND_RPC_SUBMITBLOCK::response& res, epee::json_rpc::error& error_resp, const connection_context *ctx)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PERF_TIMER(on_submitblock);
|
|
|
|
PERF_TIMER(on_submitblock);
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -1183,7 +1197,7 @@ namespace cryptonote
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool core_rpc_server::on_generateblocks(const COMMAND_RPC_GENERATEBLOCKS::request& req, COMMAND_RPC_GENERATEBLOCKS::response& res, epee::json_rpc::error& error_resp)
|
|
|
|
bool core_rpc_server::on_generateblocks(const COMMAND_RPC_GENERATEBLOCKS::request& req, COMMAND_RPC_GENERATEBLOCKS::response& res, epee::json_rpc::error& error_resp, const connection_context *ctx)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PERF_TIMER(on_generateblocks);
|
|
|
|
PERF_TIMER(on_generateblocks);
|
|
|
|
|
|
|
|
|
|
|
@ -1212,7 +1226,7 @@ namespace cryptonote
|
|
|
|
|
|
|
|
|
|
|
|
for(size_t i = 0; i < req.amount_of_blocks; i++)
|
|
|
|
for(size_t i = 0; i < req.amount_of_blocks; i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
r = on_getblocktemplate(template_req, template_res, error_resp);
|
|
|
|
r = on_getblocktemplate(template_req, template_res, error_resp, ctx);
|
|
|
|
res.status = template_res.status;
|
|
|
|
res.status = template_res.status;
|
|
|
|
|
|
|
|
|
|
|
|
if (!r) return false;
|
|
|
|
if (!r) return false;
|
|
|
@ -1234,7 +1248,7 @@ namespace cryptonote
|
|
|
|
miner::find_nonce_for_given_block(b, template_res.difficulty, template_res.height);
|
|
|
|
miner::find_nonce_for_given_block(b, template_res.difficulty, template_res.height);
|
|
|
|
|
|
|
|
|
|
|
|
submit_req.front() = string_tools::buff_to_hex_nodelimer(block_to_blob(b));
|
|
|
|
submit_req.front() = string_tools::buff_to_hex_nodelimer(block_to_blob(b));
|
|
|
|
r = on_submitblock(submit_req, submit_res, error_resp);
|
|
|
|
r = on_submitblock(submit_req, submit_res, error_resp, ctx);
|
|
|
|
res.status = submit_res.status;
|
|
|
|
res.status = submit_res.status;
|
|
|
|
|
|
|
|
|
|
|
|
if (!r) return false;
|
|
|
|
if (!r) return false;
|
|
|
@ -1343,7 +1357,7 @@ namespace cryptonote
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool core_rpc_server::on_get_last_block_header(const COMMAND_RPC_GET_LAST_BLOCK_HEADER::request& req, COMMAND_RPC_GET_LAST_BLOCK_HEADER::response& res, epee::json_rpc::error& error_resp)
|
|
|
|
bool core_rpc_server::on_get_last_block_header(const COMMAND_RPC_GET_LAST_BLOCK_HEADER::request& req, COMMAND_RPC_GET_LAST_BLOCK_HEADER::response& res, epee::json_rpc::error& error_resp, const connection_context *ctx)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PERF_TIMER(on_get_last_block_header);
|
|
|
|
PERF_TIMER(on_get_last_block_header);
|
|
|
|
bool r;
|
|
|
|
bool r;
|
|
|
@ -1373,7 +1387,8 @@ namespace cryptonote
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool core_rpc_server::on_get_block_header_by_hash(const COMMAND_RPC_GET_BLOCK_HEADER_BY_HASH::request& req, COMMAND_RPC_GET_BLOCK_HEADER_BY_HASH::response& res, epee::json_rpc::error& error_resp){
|
|
|
|
bool core_rpc_server::on_get_block_header_by_hash(const COMMAND_RPC_GET_BLOCK_HEADER_BY_HASH::request& req, COMMAND_RPC_GET_BLOCK_HEADER_BY_HASH::response& res, epee::json_rpc::error& error_resp, const connection_context *ctx)
|
|
|
|
|
|
|
|
{
|
|
|
|
PERF_TIMER(on_get_block_header_by_hash);
|
|
|
|
PERF_TIMER(on_get_block_header_by_hash);
|
|
|
|
bool r;
|
|
|
|
bool r;
|
|
|
|
if (use_bootstrap_daemon_if_necessary<COMMAND_RPC_GET_BLOCK_HEADER_BY_HASH>(invoke_http_mode::JON_RPC, "getblockheaderbyhash", req, res, r))
|
|
|
|
if (use_bootstrap_daemon_if_necessary<COMMAND_RPC_GET_BLOCK_HEADER_BY_HASH>(invoke_http_mode::JON_RPC, "getblockheaderbyhash", req, res, r))
|
|
|
@ -1414,7 +1429,8 @@ namespace cryptonote
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool core_rpc_server::on_get_block_headers_range(const COMMAND_RPC_GET_BLOCK_HEADERS_RANGE::request& req, COMMAND_RPC_GET_BLOCK_HEADERS_RANGE::response& res, epee::json_rpc::error& error_resp){
|
|
|
|
bool core_rpc_server::on_get_block_headers_range(const COMMAND_RPC_GET_BLOCK_HEADERS_RANGE::request& req, COMMAND_RPC_GET_BLOCK_HEADERS_RANGE::response& res, epee::json_rpc::error& error_resp, const connection_context *ctx)
|
|
|
|
|
|
|
|
{
|
|
|
|
PERF_TIMER(on_get_block_headers_range);
|
|
|
|
PERF_TIMER(on_get_block_headers_range);
|
|
|
|
bool r;
|
|
|
|
bool r;
|
|
|
|
if (use_bootstrap_daemon_if_necessary<COMMAND_RPC_GET_BLOCK_HEADERS_RANGE>(invoke_http_mode::JON_RPC, "getblockheadersrange", req, res, r))
|
|
|
|
if (use_bootstrap_daemon_if_necessary<COMMAND_RPC_GET_BLOCK_HEADERS_RANGE>(invoke_http_mode::JON_RPC, "getblockheadersrange", req, res, r))
|
|
|
@ -1464,7 +1480,8 @@ namespace cryptonote
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool core_rpc_server::on_get_block_header_by_height(const COMMAND_RPC_GET_BLOCK_HEADER_BY_HEIGHT::request& req, COMMAND_RPC_GET_BLOCK_HEADER_BY_HEIGHT::response& res, epee::json_rpc::error& error_resp){
|
|
|
|
bool core_rpc_server::on_get_block_header_by_height(const COMMAND_RPC_GET_BLOCK_HEADER_BY_HEIGHT::request& req, COMMAND_RPC_GET_BLOCK_HEADER_BY_HEIGHT::response& res, epee::json_rpc::error& error_resp, const connection_context *ctx)
|
|
|
|
|
|
|
|
{
|
|
|
|
PERF_TIMER(on_get_block_header_by_height);
|
|
|
|
PERF_TIMER(on_get_block_header_by_height);
|
|
|
|
bool r;
|
|
|
|
bool r;
|
|
|
|
if (use_bootstrap_daemon_if_necessary<COMMAND_RPC_GET_BLOCK_HEADER_BY_HEIGHT>(invoke_http_mode::JON_RPC, "getblockheaderbyheight", req, res, r))
|
|
|
|
if (use_bootstrap_daemon_if_necessary<COMMAND_RPC_GET_BLOCK_HEADER_BY_HEIGHT>(invoke_http_mode::JON_RPC, "getblockheaderbyheight", req, res, r))
|
|
|
@ -1496,7 +1513,8 @@ namespace cryptonote
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool core_rpc_server::on_get_block(const COMMAND_RPC_GET_BLOCK::request& req, COMMAND_RPC_GET_BLOCK::response& res, epee::json_rpc::error& error_resp){
|
|
|
|
bool core_rpc_server::on_get_block(const COMMAND_RPC_GET_BLOCK::request& req, COMMAND_RPC_GET_BLOCK::response& res, epee::json_rpc::error& error_resp, const connection_context *ctx)
|
|
|
|
|
|
|
|
{
|
|
|
|
PERF_TIMER(on_get_block);
|
|
|
|
PERF_TIMER(on_get_block);
|
|
|
|
bool r;
|
|
|
|
bool r;
|
|
|
|
if (use_bootstrap_daemon_if_necessary<COMMAND_RPC_GET_BLOCK>(invoke_http_mode::JON_RPC, "getblock", req, res, r))
|
|
|
|
if (use_bootstrap_daemon_if_necessary<COMMAND_RPC_GET_BLOCK>(invoke_http_mode::JON_RPC, "getblock", req, res, r))
|
|
|
@ -1557,7 +1575,7 @@ namespace cryptonote
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool core_rpc_server::on_get_connections(const COMMAND_RPC_GET_CONNECTIONS::request& req, COMMAND_RPC_GET_CONNECTIONS::response& res, epee::json_rpc::error& error_resp)
|
|
|
|
bool core_rpc_server::on_get_connections(const COMMAND_RPC_GET_CONNECTIONS::request& req, COMMAND_RPC_GET_CONNECTIONS::response& res, epee::json_rpc::error& error_resp, const connection_context *ctx)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PERF_TIMER(on_get_connections);
|
|
|
|
PERF_TIMER(on_get_connections);
|
|
|
|
|
|
|
|
|
|
|
@ -1568,7 +1586,7 @@ namespace cryptonote
|
|
|
|
return true;
|
|
|
|
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)
|
|
|
|
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);
|
|
|
|
PERF_TIMER(on_get_info_json);
|
|
|
|
bool r;
|
|
|
|
bool r;
|
|
|
@ -1582,6 +1600,8 @@ namespace cryptonote
|
|
|
|
return r;
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const bool restricted = m_restricted && ctx;
|
|
|
|
|
|
|
|
|
|
|
|
crypto::hash top_hash;
|
|
|
|
crypto::hash top_hash;
|
|
|
|
m_core.get_blockchain_top(res.height, top_hash);
|
|
|
|
m_core.get_blockchain_top(res.height, top_hash);
|
|
|
|
++res.height; // turn top block height into blockchain height
|
|
|
|
++res.height; // turn top block height into blockchain height
|
|
|
@ -1591,13 +1611,13 @@ namespace cryptonote
|
|
|
|
res.target = m_core.get_blockchain_storage().get_current_hard_fork_version() < 2 ? DIFFICULTY_TARGET_V1 : DIFFICULTY_TARGET_V2;
|
|
|
|
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_count = m_core.get_blockchain_storage().get_total_transactions() - res.height; //without coinbase
|
|
|
|
res.tx_pool_size = m_core.get_pool_transactions_count();
|
|
|
|
res.tx_pool_size = m_core.get_pool_transactions_count();
|
|
|
|
res.alt_blocks_count = m_restricted ? 0 : m_core.get_blockchain_storage().get_alternative_blocks_count();
|
|
|
|
res.alt_blocks_count = restricted ? 0 : m_core.get_blockchain_storage().get_alternative_blocks_count();
|
|
|
|
uint64_t total_conn = m_restricted ? 0 : m_p2p.get_connections_count();
|
|
|
|
uint64_t total_conn = restricted ? 0 : m_p2p.get_connections_count();
|
|
|
|
res.outgoing_connections_count = m_restricted ? 0 : m_p2p.get_outgoing_connections_count();
|
|
|
|
res.outgoing_connections_count = restricted ? 0 : m_p2p.get_outgoing_connections_count();
|
|
|
|
res.incoming_connections_count = m_restricted ? 0 : (total_conn - res.outgoing_connections_count);
|
|
|
|
res.incoming_connections_count = restricted ? 0 : (total_conn - res.outgoing_connections_count);
|
|
|
|
res.rpc_connections_count = m_restricted ? 0 : get_connections_count();
|
|
|
|
res.rpc_connections_count = restricted ? 0 : get_connections_count();
|
|
|
|
res.white_peerlist_size = m_restricted ? 0 : m_p2p.get_peerlist_manager().get_white_peers_count();
|
|
|
|
res.white_peerlist_size = restricted ? 0 : m_p2p.get_peerlist_manager().get_white_peers_count();
|
|
|
|
res.grey_peerlist_size = m_restricted ? 0 : m_p2p.get_peerlist_manager().get_gray_peers_count();
|
|
|
|
res.grey_peerlist_size = restricted ? 0 : m_p2p.get_peerlist_manager().get_gray_peers_count();
|
|
|
|
|
|
|
|
|
|
|
|
cryptonote::network_type net_type = nettype();
|
|
|
|
cryptonote::network_type net_type = nettype();
|
|
|
|
res.mainnet = net_type == MAINNET;
|
|
|
|
res.mainnet = net_type == MAINNET;
|
|
|
@ -1609,25 +1629,25 @@ namespace cryptonote
|
|
|
|
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.status = CORE_RPC_STATUS_OK;
|
|
|
|
res.start_time = m_restricted ? 0 : (uint64_t)m_core.get_start_time();
|
|
|
|
res.start_time = restricted ? 0 : (uint64_t)m_core.get_start_time();
|
|
|
|
res.free_space = m_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();
|
|
|
|
res.bootstrap_daemon_address = m_restricted ? "" : m_bootstrap_daemon_address;
|
|
|
|
res.bootstrap_daemon_address = restricted ? "" : m_bootstrap_daemon_address;
|
|
|
|
res.height_without_bootstrap = m_restricted ? 0 : res.height;
|
|
|
|
res.height_without_bootstrap = restricted ? 0 : res.height;
|
|
|
|
if (m_restricted)
|
|
|
|
if (restricted)
|
|
|
|
res.was_bootstrap_ever_used = false;
|
|
|
|
res.was_bootstrap_ever_used = false;
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
boost::shared_lock<boost::shared_mutex> lock(m_bootstrap_daemon_mutex);
|
|
|
|
boost::shared_lock<boost::shared_mutex> lock(m_bootstrap_daemon_mutex);
|
|
|
|
res.was_bootstrap_ever_used = m_was_bootstrap_ever_used;
|
|
|
|
res.was_bootstrap_ever_used = m_was_bootstrap_ever_used;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
res.database_size = m_restricted ? 0 : m_core.get_blockchain_storage().get_db().get_database_size();
|
|
|
|
res.database_size = restricted ? 0 : m_core.get_blockchain_storage().get_db().get_database_size();
|
|
|
|
res.update_available = m_restricted ? false : m_core.is_update_available();
|
|
|
|
res.update_available = restricted ? false : m_core.is_update_available();
|
|
|
|
res.version = m_restricted ? "" : MONERO_VERSION;
|
|
|
|
res.version = restricted ? "" : MONERO_VERSION;
|
|
|
|
return true;
|
|
|
|
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)
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PERF_TIMER(on_hard_fork_info);
|
|
|
|
PERF_TIMER(on_hard_fork_info);
|
|
|
|
bool r;
|
|
|
|
bool r;
|
|
|
@ -1643,7 +1663,7 @@ namespace cryptonote
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool core_rpc_server::on_get_bans(const COMMAND_RPC_GETBANS::request& req, COMMAND_RPC_GETBANS::response& res, epee::json_rpc::error& error_resp)
|
|
|
|
bool core_rpc_server::on_get_bans(const COMMAND_RPC_GETBANS::request& req, COMMAND_RPC_GETBANS::response& res, epee::json_rpc::error& error_resp, const connection_context *ctx)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PERF_TIMER(on_get_bans);
|
|
|
|
PERF_TIMER(on_get_bans);
|
|
|
|
|
|
|
|
|
|
|
@ -1667,7 +1687,7 @@ namespace cryptonote
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool core_rpc_server::on_set_bans(const COMMAND_RPC_SETBANS::request& req, COMMAND_RPC_SETBANS::response& res, epee::json_rpc::error& error_resp)
|
|
|
|
bool core_rpc_server::on_set_bans(const COMMAND_RPC_SETBANS::request& req, COMMAND_RPC_SETBANS::response& res, epee::json_rpc::error& error_resp, const connection_context *ctx)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PERF_TIMER(on_set_bans);
|
|
|
|
PERF_TIMER(on_set_bans);
|
|
|
|
|
|
|
|
|
|
|
@ -1697,7 +1717,7 @@ namespace cryptonote
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool core_rpc_server::on_flush_txpool(const COMMAND_RPC_FLUSH_TRANSACTION_POOL::request& req, COMMAND_RPC_FLUSH_TRANSACTION_POOL::response& res, epee::json_rpc::error& error_resp)
|
|
|
|
bool core_rpc_server::on_flush_txpool(const COMMAND_RPC_FLUSH_TRANSACTION_POOL::request& req, COMMAND_RPC_FLUSH_TRANSACTION_POOL::response& res, epee::json_rpc::error& error_resp, const connection_context *ctx)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PERF_TIMER(on_flush_txpool);
|
|
|
|
PERF_TIMER(on_flush_txpool);
|
|
|
|
|
|
|
|
|
|
|
@ -1752,7 +1772,7 @@ namespace cryptonote
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool core_rpc_server::on_get_output_histogram(const COMMAND_RPC_GET_OUTPUT_HISTOGRAM::request& req, COMMAND_RPC_GET_OUTPUT_HISTOGRAM::response& res, epee::json_rpc::error& error_resp)
|
|
|
|
bool core_rpc_server::on_get_output_histogram(const COMMAND_RPC_GET_OUTPUT_HISTOGRAM::request& req, COMMAND_RPC_GET_OUTPUT_HISTOGRAM::response& res, epee::json_rpc::error& error_resp, const connection_context *ctx)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PERF_TIMER(on_get_output_histogram);
|
|
|
|
PERF_TIMER(on_get_output_histogram);
|
|
|
|
bool r;
|
|
|
|
bool r;
|
|
|
@ -1782,7 +1802,7 @@ namespace cryptonote
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool core_rpc_server::on_get_version(const COMMAND_RPC_GET_VERSION::request& req, COMMAND_RPC_GET_VERSION::response& res, epee::json_rpc::error& error_resp)
|
|
|
|
bool core_rpc_server::on_get_version(const COMMAND_RPC_GET_VERSION::request& req, COMMAND_RPC_GET_VERSION::response& res, epee::json_rpc::error& error_resp, const connection_context *ctx)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PERF_TIMER(on_get_version);
|
|
|
|
PERF_TIMER(on_get_version);
|
|
|
|
bool r;
|
|
|
|
bool r;
|
|
|
@ -1794,7 +1814,7 @@ namespace cryptonote
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool core_rpc_server::on_get_coinbase_tx_sum(const COMMAND_RPC_GET_COINBASE_TX_SUM::request& req, COMMAND_RPC_GET_COINBASE_TX_SUM::response& res, epee::json_rpc::error& error_resp)
|
|
|
|
bool core_rpc_server::on_get_coinbase_tx_sum(const COMMAND_RPC_GET_COINBASE_TX_SUM::request& req, COMMAND_RPC_GET_COINBASE_TX_SUM::response& res, epee::json_rpc::error& error_resp, const connection_context *ctx)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PERF_TIMER(on_get_coinbase_tx_sum);
|
|
|
|
PERF_TIMER(on_get_coinbase_tx_sum);
|
|
|
|
std::pair<uint64_t, uint64_t> amounts = m_core.get_coinbase_tx_sum(req.height, req.count);
|
|
|
|
std::pair<uint64_t, uint64_t> amounts = m_core.get_coinbase_tx_sum(req.height, req.count);
|
|
|
@ -1804,7 +1824,7 @@ namespace cryptonote
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool core_rpc_server::on_get_base_fee_estimate(const COMMAND_RPC_GET_BASE_FEE_ESTIMATE::request& req, COMMAND_RPC_GET_BASE_FEE_ESTIMATE::response& res, epee::json_rpc::error& error_resp)
|
|
|
|
bool core_rpc_server::on_get_base_fee_estimate(const COMMAND_RPC_GET_BASE_FEE_ESTIMATE::request& req, COMMAND_RPC_GET_BASE_FEE_ESTIMATE::response& res, epee::json_rpc::error& error_resp, const connection_context *ctx)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PERF_TIMER(on_get_base_fee_estimate);
|
|
|
|
PERF_TIMER(on_get_base_fee_estimate);
|
|
|
|
bool r;
|
|
|
|
bool r;
|
|
|
@ -1817,7 +1837,7 @@ namespace cryptonote
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool core_rpc_server::on_get_alternate_chains(const COMMAND_RPC_GET_ALTERNATE_CHAINS::request& req, COMMAND_RPC_GET_ALTERNATE_CHAINS::response& res, epee::json_rpc::error& error_resp)
|
|
|
|
bool core_rpc_server::on_get_alternate_chains(const COMMAND_RPC_GET_ALTERNATE_CHAINS::request& req, COMMAND_RPC_GET_ALTERNATE_CHAINS::response& res, epee::json_rpc::error& error_resp, const connection_context *ctx)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PERF_TIMER(on_get_alternate_chains);
|
|
|
|
PERF_TIMER(on_get_alternate_chains);
|
|
|
|
try
|
|
|
|
try
|
|
|
@ -1848,7 +1868,7 @@ namespace cryptonote
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool core_rpc_server::on_get_limit(const COMMAND_RPC_GET_LIMIT::request& req, COMMAND_RPC_GET_LIMIT::response& res)
|
|
|
|
bool core_rpc_server::on_get_limit(const COMMAND_RPC_GET_LIMIT::request& req, COMMAND_RPC_GET_LIMIT::response& res, const connection_context *ctx)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PERF_TIMER(on_get_limit);
|
|
|
|
PERF_TIMER(on_get_limit);
|
|
|
|
bool r;
|
|
|
|
bool r;
|
|
|
@ -1861,7 +1881,7 @@ namespace cryptonote
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool core_rpc_server::on_set_limit(const COMMAND_RPC_SET_LIMIT::request& req, COMMAND_RPC_SET_LIMIT::response& res)
|
|
|
|
bool core_rpc_server::on_set_limit(const COMMAND_RPC_SET_LIMIT::request& req, COMMAND_RPC_SET_LIMIT::response& res, const connection_context *ctx)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PERF_TIMER(on_set_limit);
|
|
|
|
PERF_TIMER(on_set_limit);
|
|
|
|
// -1 = reset to default
|
|
|
|
// -1 = reset to default
|
|
|
@ -1901,7 +1921,7 @@ namespace cryptonote
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool core_rpc_server::on_out_peers(const COMMAND_RPC_OUT_PEERS::request& req, COMMAND_RPC_OUT_PEERS::response& res)
|
|
|
|
bool core_rpc_server::on_out_peers(const COMMAND_RPC_OUT_PEERS::request& req, COMMAND_RPC_OUT_PEERS::response& res, const connection_context *ctx)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PERF_TIMER(on_out_peers);
|
|
|
|
PERF_TIMER(on_out_peers);
|
|
|
|
size_t n_connections = m_p2p.get_outgoing_connections_count();
|
|
|
|
size_t n_connections = m_p2p.get_outgoing_connections_count();
|
|
|
@ -1913,7 +1933,7 @@ namespace cryptonote
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool core_rpc_server::on_in_peers(const COMMAND_RPC_IN_PEERS::request& req, COMMAND_RPC_IN_PEERS::response& res)
|
|
|
|
bool core_rpc_server::on_in_peers(const COMMAND_RPC_IN_PEERS::request& req, COMMAND_RPC_IN_PEERS::response& res, const connection_context *ctx)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PERF_TIMER(on_in_peers);
|
|
|
|
PERF_TIMER(on_in_peers);
|
|
|
|
size_t n_connections = m_p2p.get_incoming_connections_count();
|
|
|
|
size_t n_connections = m_p2p.get_incoming_connections_count();
|
|
|
@ -1925,7 +1945,7 @@ namespace cryptonote
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool core_rpc_server::on_start_save_graph(const COMMAND_RPC_START_SAVE_GRAPH::request& req, COMMAND_RPC_START_SAVE_GRAPH::response& res)
|
|
|
|
bool core_rpc_server::on_start_save_graph(const COMMAND_RPC_START_SAVE_GRAPH::request& req, COMMAND_RPC_START_SAVE_GRAPH::response& res, const connection_context *ctx)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PERF_TIMER(on_start_save_graph);
|
|
|
|
PERF_TIMER(on_start_save_graph);
|
|
|
|
m_p2p.set_save_graph(true);
|
|
|
|
m_p2p.set_save_graph(true);
|
|
|
@ -1933,7 +1953,7 @@ namespace cryptonote
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool core_rpc_server::on_stop_save_graph(const COMMAND_RPC_STOP_SAVE_GRAPH::request& req, COMMAND_RPC_STOP_SAVE_GRAPH::response& res)
|
|
|
|
bool core_rpc_server::on_stop_save_graph(const COMMAND_RPC_STOP_SAVE_GRAPH::request& req, COMMAND_RPC_STOP_SAVE_GRAPH::response& res, const connection_context *ctx)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PERF_TIMER(on_stop_save_graph);
|
|
|
|
PERF_TIMER(on_stop_save_graph);
|
|
|
|
m_p2p.set_save_graph(false);
|
|
|
|
m_p2p.set_save_graph(false);
|
|
|
@ -1941,7 +1961,7 @@ namespace cryptonote
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool core_rpc_server::on_update(const COMMAND_RPC_UPDATE::request& req, COMMAND_RPC_UPDATE::response& res)
|
|
|
|
bool core_rpc_server::on_update(const COMMAND_RPC_UPDATE::request& req, COMMAND_RPC_UPDATE::response& res, const connection_context *ctx)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PERF_TIMER(on_update);
|
|
|
|
PERF_TIMER(on_update);
|
|
|
|
static const char software[] = "monero";
|
|
|
|
static const char software[] = "monero";
|
|
|
@ -2036,7 +2056,7 @@ namespace cryptonote
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool core_rpc_server::on_pop_blocks(const COMMAND_RPC_POP_BLOCKS::request& req, COMMAND_RPC_POP_BLOCKS::response& res)
|
|
|
|
bool core_rpc_server::on_pop_blocks(const COMMAND_RPC_POP_BLOCKS::request& req, COMMAND_RPC_POP_BLOCKS::response& res, const connection_context *ctx)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PERF_TIMER(on_pop_blocks);
|
|
|
|
PERF_TIMER(on_pop_blocks);
|
|
|
|
|
|
|
|
|
|
|
@ -2048,7 +2068,7 @@ namespace cryptonote
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool core_rpc_server::on_relay_tx(const COMMAND_RPC_RELAY_TX::request& req, COMMAND_RPC_RELAY_TX::response& res, epee::json_rpc::error& error_resp)
|
|
|
|
bool core_rpc_server::on_relay_tx(const COMMAND_RPC_RELAY_TX::request& req, COMMAND_RPC_RELAY_TX::response& res, epee::json_rpc::error& error_resp, const connection_context *ctx)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PERF_TIMER(on_relay_tx);
|
|
|
|
PERF_TIMER(on_relay_tx);
|
|
|
|
|
|
|
|
|
|
|
@ -2094,7 +2114,7 @@ namespace cryptonote
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool core_rpc_server::on_sync_info(const COMMAND_RPC_SYNC_INFO::request& req, COMMAND_RPC_SYNC_INFO::response& res, epee::json_rpc::error& error_resp)
|
|
|
|
bool core_rpc_server::on_sync_info(const COMMAND_RPC_SYNC_INFO::request& req, COMMAND_RPC_SYNC_INFO::response& res, epee::json_rpc::error& error_resp, const connection_context *ctx)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PERF_TIMER(on_sync_info);
|
|
|
|
PERF_TIMER(on_sync_info);
|
|
|
|
|
|
|
|
|
|
|
@ -2121,7 +2141,7 @@ namespace cryptonote
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool core_rpc_server::on_get_txpool_backlog(const COMMAND_RPC_GET_TRANSACTION_POOL_BACKLOG::request& req, COMMAND_RPC_GET_TRANSACTION_POOL_BACKLOG::response& res, epee::json_rpc::error& error_resp)
|
|
|
|
bool core_rpc_server::on_get_txpool_backlog(const COMMAND_RPC_GET_TRANSACTION_POOL_BACKLOG::request& req, COMMAND_RPC_GET_TRANSACTION_POOL_BACKLOG::response& res, epee::json_rpc::error& error_resp, const connection_context *ctx)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PERF_TIMER(on_get_txpool_backlog);
|
|
|
|
PERF_TIMER(on_get_txpool_backlog);
|
|
|
|
bool r;
|
|
|
|
bool r;
|
|
|
@ -2139,7 +2159,7 @@ namespace cryptonote
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool core_rpc_server::on_get_output_distribution(const COMMAND_RPC_GET_OUTPUT_DISTRIBUTION::request& req, COMMAND_RPC_GET_OUTPUT_DISTRIBUTION::response& res, epee::json_rpc::error& error_resp)
|
|
|
|
bool core_rpc_server::on_get_output_distribution(const COMMAND_RPC_GET_OUTPUT_DISTRIBUTION::request& req, COMMAND_RPC_GET_OUTPUT_DISTRIBUTION::response& res, epee::json_rpc::error& error_resp, const connection_context *ctx)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PERF_TIMER(on_get_output_distribution);
|
|
|
|
PERF_TIMER(on_get_output_distribution);
|
|
|
|
bool r;
|
|
|
|
bool r;
|
|
|
|