aboutsummaryrefslogtreecommitdiff
path: root/src/daemon/rpc_command_executor.cpp
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2016-03-26 14:30:23 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2016-03-26 21:10:43 +0000
commit600a3cf0c0ca0a99dbdc91d32138db3c8aa4165c (patch)
treeedc8745f2439b59a82ee834df9d43721bc6bd475 /src/daemon/rpc_command_executor.cpp
parentwallet: handle rare case where fee adjustment can bump to the next kB (diff)
downloadmonero-600a3cf0c0ca0a99dbdc91d32138db3c8aa4165c.tar.xz
New RPC and daemon command to get output histogram
This is a list of existing output amounts along with the number of outputs of that amount in the blockchain. The daemon command takes: - no parameters: all outputs with at least 3 instances - one parameter: all outputs with at least that many instances - two parameters: all outputs within that many instances The default starts at 3 to avoid massive spamming of all dust outputs in the blockchain, and is the current minimum mixin requirement. An optional vector of amounts may be passed, to request histogram only for those outputs.
Diffstat (limited to 'src/daemon/rpc_command_executor.cpp')
-rw-r--r--src/daemon/rpc_command_executor.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/daemon/rpc_command_executor.cpp b/src/daemon/rpc_command_executor.cpp
index 15ddc081f..933c93ed7 100644
--- a/src/daemon/rpc_command_executor.cpp
+++ b/src/daemon/rpc_command_executor.cpp
@@ -1203,5 +1203,41 @@ bool t_rpc_command_executor::flush_txpool(const std::string &txid)
return true;
}
+bool t_rpc_command_executor::output_histogram(uint64_t min_count, uint64_t max_count)
+{
+ cryptonote::COMMAND_RPC_GET_OUTPUT_HISTOGRAM::request req;
+ cryptonote::COMMAND_RPC_GET_OUTPUT_HISTOGRAM::response res;
+ std::string fail_message = "Unsuccessful";
+ epee::json_rpc::error error_resp;
+
+ req.min_count = min_count;
+ req.max_count = max_count;
+
+ if (m_is_rpc)
+ {
+ if (!m_rpc_client->json_rpc_request(req, res, "get_output_histogram", fail_message.c_str()))
+ {
+ return true;
+ }
+ }
+ else
+ {
+ if (!m_rpc_server->on_get_output_histogram(req, res, error_resp))
+ {
+ tools::fail_msg_writer() << fail_message.c_str();
+ return true;
+ }
+ }
+
+ std::sort(res.histogram.begin(), res.histogram.end(),
+ [](const cryptonote::COMMAND_RPC_GET_OUTPUT_HISTOGRAM::entry &e1, const cryptonote::COMMAND_RPC_GET_OUTPUT_HISTOGRAM::entry &e2)->bool { return e1.instances < e2.instances; });
+ for (const auto &e: res.histogram)
+ {
+ tools::msg_writer() << e.instances << " " << cryptonote::print_money(e.amount);
+ }
+
+ return true;
+}
+
}// namespace daemonize