aboutsummaryrefslogtreecommitdiff
path: root/src/daemon
diff options
context:
space:
mode:
Diffstat (limited to 'src/daemon')
-rw-r--r--src/daemon/command_parser_executor.cpp18
-rw-r--r--src/daemon/command_parser_executor.h2
-rw-r--r--src/daemon/command_server.cpp5
-rw-r--r--src/daemon/core.h1
-rw-r--r--src/daemon/rpc_command_executor.cpp38
-rw-r--r--src/daemon/rpc_command_executor.h2
6 files changed, 64 insertions, 2 deletions
diff --git a/src/daemon/command_parser_executor.cpp b/src/daemon/command_parser_executor.cpp
index 0b42257e7..166fe04ca 100644
--- a/src/daemon/command_parser_executor.cpp
+++ b/src/daemon/command_parser_executor.cpp
@@ -439,5 +439,23 @@ bool t_command_parser_executor::flush_txpool(const std::vector<std::string>& arg
return m_executor.flush_txpool(txid);
}
+bool t_command_parser_executor::output_histogram(const std::vector<std::string>& args)
+{
+ if (args.size() > 2) return false;
+
+ uint64_t min_count = 3;
+ uint64_t max_count = 0;
+
+ if (args.size() >= 1)
+ {
+ min_count = boost::lexical_cast<uint64_t>(args[0]);
+ }
+ if (args.size() >= 2)
+ {
+ max_count = boost::lexical_cast<uint64_t>(args[1]);
+ }
+ return m_executor.output_histogram(min_count, max_count);
+}
+
} // namespace daemonize
diff --git a/src/daemon/command_parser_executor.h b/src/daemon/command_parser_executor.h
index 51c55a8c0..11df92a5e 100644
--- a/src/daemon/command_parser_executor.h
+++ b/src/daemon/command_parser_executor.h
@@ -114,6 +114,8 @@ public:
bool unban(const std::vector<std::string>& args);
bool flush_txpool(const std::vector<std::string>& args);
+
+ bool output_histogram(const std::vector<std::string>& args);
};
} // namespace daemonize
diff --git a/src/daemon/command_server.cpp b/src/daemon/command_server.cpp
index 206de9d4a..aabc2f09a 100644
--- a/src/daemon/command_server.cpp
+++ b/src/daemon/command_server.cpp
@@ -214,6 +214,11 @@ t_command_server::t_command_server(
, std::bind(&t_command_parser_executor::flush_txpool, &m_parser, p::_1)
, "Flush a transaction from the tx pool by its txid, or the whole tx pool"
);
+ m_command_lookup.set_handler(
+ "output_histogram"
+ , std::bind(&t_command_parser_executor::output_histogram, &m_parser, p::_1)
+ , "Print output histogram (amount, instances)"
+ );
}
bool t_command_server::process_command_str(const std::string& cmd)
diff --git a/src/daemon/core.h b/src/daemon/core.h
index 2208ef25a..2b7f0d177 100644
--- a/src/daemon/core.h
+++ b/src/daemon/core.h
@@ -28,7 +28,6 @@
#pragma once
-#include "cryptonote_core/checkpoints_create.h"
#include "cryptonote_core/cryptonote_core.h"
#include "cryptonote_protocol/cryptonote_protocol_handler.h"
#include "misc_log_ex.h"
diff --git a/src/daemon/rpc_command_executor.cpp b/src/daemon/rpc_command_executor.cpp
index ffda7cde3..933c93ed7 100644
--- a/src/daemon/rpc_command_executor.cpp
+++ b/src/daemon/rpc_command_executor.cpp
@@ -558,6 +558,7 @@ bool t_rpc_command_executor::print_transaction(crypto::hash transaction_hash) {
std::string fail_message = "Problem fetching transaction";
+ req.txs_hashes.push_back(epee::string_tools::pod_to_hex(transaction_hash));
if (m_is_rpc)
{
if (!m_rpc_client->rpc_request(req, res, "/gettransactions", fail_message.c_str()))
@@ -567,7 +568,6 @@ bool t_rpc_command_executor::print_transaction(crypto::hash transaction_hash) {
}
else
{
- req.txs_hashes.push_back(epee::string_tools::pod_to_hex(transaction_hash));
if (!m_rpc_server->on_get_transactions(req, res) || res.status != CORE_RPC_STATUS_OK)
{
tools::fail_msg_writer() << fail_message.c_str();
@@ -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
diff --git a/src/daemon/rpc_command_executor.h b/src/daemon/rpc_command_executor.h
index bc3f2d5c5..7e73e7faf 100644
--- a/src/daemon/rpc_command_executor.h
+++ b/src/daemon/rpc_command_executor.h
@@ -132,6 +132,8 @@ public:
bool unban(const std::string &ip);
bool flush_txpool(const std::string &txid);
+
+ bool output_histogram(uint64_t min_count, uint64_t max_count);
};
} // namespace daemonize