aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2017-10-15 18:48:19 +0200
committerRiccardo Spagni <ric@spagni.net>2017-10-15 18:48:19 +0200
commitf484b162db6ff0eeab2d7da3f9c54ccfd5741791 (patch)
treea3801dcafb8f0a24c51658c92e2d8aeb0463b687 /src
parentMerge pull request #2597 (diff)
parentdaemon: use @N syntax to output_histogram for specific amounts (diff)
downloadmonero-f484b162db6ff0eeab2d7da3f9c54ccfd5741791.tar.xz
Merge pull request #2599
b776c725 daemon: use @N syntax to output_histogram for specific amounts (moneromooo-monero)
Diffstat (limited to 'src')
-rw-r--r--src/daemon/command_parser_executor.cpp32
-rw-r--r--src/daemon/rpc_command_executor.cpp3
-rw-r--r--src/daemon/rpc_command_executor.h2
3 files changed, 26 insertions, 11 deletions
diff --git a/src/daemon/command_parser_executor.cpp b/src/daemon/command_parser_executor.cpp
index ddb5e95df..c85e5edb5 100644
--- a/src/daemon/command_parser_executor.cpp
+++ b/src/daemon/command_parser_executor.cpp
@@ -503,20 +503,34 @@ bool t_command_parser_executor::flush_txpool(const std::vector<std::string>& arg
bool t_command_parser_executor::output_histogram(const std::vector<std::string>& args)
{
- if (args.size() > 2) return false;
-
+ std::vector<uint64_t> amounts;
uint64_t min_count = 3;
uint64_t max_count = 0;
+ size_t n_raw = 0;
- if (args.size() >= 1)
- {
- min_count = boost::lexical_cast<uint64_t>(args[0]);
- }
- if (args.size() >= 2)
+ for (size_t n = 0; n < args.size(); ++n)
{
- max_count = boost::lexical_cast<uint64_t>(args[1]);
+ if (args[n][0] == '@')
+ {
+ amounts.push_back(boost::lexical_cast<uint64_t>(args[n].c_str() + 1));
+ }
+ else if (n_raw == 0)
+ {
+ min_count = boost::lexical_cast<uint64_t>(args[n]);
+ n_raw++;
+ }
+ else if (n_raw == 1)
+ {
+ max_count = boost::lexical_cast<uint64_t>(args[n]);
+ n_raw++;
+ }
+ else
+ {
+ std::cout << "Invalid syntax: more than two non-amount parameters" << std::endl;
+ return true;
+ }
}
- return m_executor.output_histogram(min_count, max_count);
+ return m_executor.output_histogram(amounts, min_count, max_count);
}
bool t_command_parser_executor::print_coinbase_tx_sum(const std::vector<std::string>& args)
diff --git a/src/daemon/rpc_command_executor.cpp b/src/daemon/rpc_command_executor.cpp
index be1ed20ba..867c523c9 100644
--- a/src/daemon/rpc_command_executor.cpp
+++ b/src/daemon/rpc_command_executor.cpp
@@ -1490,13 +1490,14 @@ 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)
+bool t_rpc_command_executor::output_histogram(const std::vector<uint64_t> &amounts, 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.amounts = amounts;
req.min_count = min_count;
req.max_count = max_count;
req.unlocked = false;
diff --git a/src/daemon/rpc_command_executor.h b/src/daemon/rpc_command_executor.h
index d79707a6f..c9d0ac671 100644
--- a/src/daemon/rpc_command_executor.h
+++ b/src/daemon/rpc_command_executor.h
@@ -137,7 +137,7 @@ public:
bool flush_txpool(const std::string &txid);
- bool output_histogram(uint64_t min_count, uint64_t max_count);
+ bool output_histogram(const std::vector<uint64_t> &amounts, uint64_t min_count, uint64_t max_count);
bool print_coinbase_tx_sum(uint64_t height, uint64_t count);