mirror of
https://github.com/monero-project/monero.git
synced 2026-01-02 16:00:10 -08:00
rpc: speedup get_output_distribution
and decrease the amount of data carried around
This commit is contained in:
@@ -2133,7 +2133,7 @@ namespace cryptonote
|
||||
return false;
|
||||
}
|
||||
|
||||
res.distributions.push_back({std::move(*data), amount, req.binary});
|
||||
res.distributions.push_back({std::move(*data), amount, "", req.binary, req.compress});
|
||||
}
|
||||
}
|
||||
catch (const std::exception &e)
|
||||
@@ -2147,6 +2147,47 @@ namespace cryptonote
|
||||
return true;
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
bool core_rpc_server::on_get_output_distribution_bin(const COMMAND_RPC_GET_OUTPUT_DISTRIBUTION::request& req, COMMAND_RPC_GET_OUTPUT_DISTRIBUTION::response& res)
|
||||
{
|
||||
PERF_TIMER(on_get_output_distribution_bin);
|
||||
|
||||
bool r;
|
||||
if (use_bootstrap_daemon_if_necessary<COMMAND_RPC_GET_OUTPUT_DISTRIBUTION>(invoke_http_mode::BIN, "/get_output_distribution.bin", req, res, r))
|
||||
return r;
|
||||
|
||||
res.status = "Failed";
|
||||
|
||||
if (!req.binary)
|
||||
{
|
||||
res.status = "Binary only call";
|
||||
return false;
|
||||
}
|
||||
try
|
||||
{
|
||||
// 0 is placeholder for the whole chain
|
||||
const uint64_t req_to_height = req.to_height ? req.to_height : (m_core.get_current_blockchain_height() - 1);
|
||||
for (uint64_t amount: req.amounts)
|
||||
{
|
||||
auto data = rpc::RpcHandler::get_output_distribution([this](uint64_t amount, uint64_t from, uint64_t to, uint64_t &start_height, std::vector<uint64_t> &distribution, uint64_t &base) { return m_core.get_output_distribution(amount, from, to, start_height, distribution, base); }, amount, req.from_height, req_to_height, req.cumulative);
|
||||
if (!data)
|
||||
{
|
||||
res.status = "Failed to get output distribution";
|
||||
return false;
|
||||
}
|
||||
|
||||
res.distributions.push_back({std::move(*data), amount, "", req.binary, req.compress});
|
||||
}
|
||||
}
|
||||
catch (const std::exception &e)
|
||||
{
|
||||
res.status = "Failed to get output distribution";
|
||||
return false;
|
||||
}
|
||||
|
||||
res.status = CORE_RPC_STATUS_OK;
|
||||
return true;
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
const command_line::arg_descriptor<std::string, false, true, 2> core_rpc_server::arg_rpc_bind_port = {
|
||||
|
||||
Reference in New Issue
Block a user