aboutsummaryrefslogtreecommitdiff
path: root/src/rpc/core_rpc_server.cpp
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2018-02-19 11:15:15 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2018-03-16 10:32:26 +0000
commit41f727ce42d0fce9e40e4da7bf4abda92eef1016 (patch)
treefec7f8482cf1fdd7e927b91dbab563e785724a5e /src/rpc/core_rpc_server.cpp
parentMerge pull request #3410 (diff)
downloadmonero-41f727ce42d0fce9e40e4da7bf4abda92eef1016.tar.xz
add RPC to get a histogram of outputs of a given amount
Diffstat (limited to 'src/rpc/core_rpc_server.cpp')
-rw-r--r--src/rpc/core_rpc_server.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp
index 0e3e6757b..f649a0ca5 100644
--- a/src/rpc/core_rpc_server.cpp
+++ b/src/rpc/core_rpc_server.cpp
@@ -2076,6 +2076,41 @@ namespace cryptonote
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)
+ {
+ try
+ {
+ for (uint64_t amount: req.amounts)
+ {
+ std::vector<uint64_t> distribution;
+ uint64_t start_height, base;
+ if (!m_core.get_output_distribution(amount, req.from_height, start_height, distribution, base))
+ {
+ error_resp.code = CORE_RPC_ERROR_CODE_INTERNAL_ERROR;
+ error_resp.message = "Failed to get rct distribution";
+ return false;
+ }
+ if (req.cumulative)
+ {
+ distribution[0] += base;
+ for (size_t n = 1; n < distribution.size(); ++n)
+ distribution[n] += distribution[n-1];
+ }
+ res.distributions.push_back({amount, start_height, std::move(distribution), base});
+ }
+ }
+ catch (const std::exception &e)
+ {
+ error_resp.code = CORE_RPC_ERROR_CODE_INTERNAL_ERROR;
+ error_resp.message = "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 = {
"rpc-bind-port"