aboutsummaryrefslogtreecommitdiff
path: root/src/daemon/command_parser_executor.cpp
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2019-05-08 18:56:47 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2019-05-09 09:13:11 +0000
commit4228ee0b9ee9096cb2a49fd09d88a5f5ae96afc1 (patch)
tree804ed88faa297a335c9a7c515dc636fffc9f4315 /src/daemon/command_parser_executor.cpp
parentdaemon: sort alt chains by height (diff)
downloadmonero-4228ee0b9ee9096cb2a49fd09d88a5f5ae96afc1.tar.xz
daemon: add optional arguments to alt_chain_info
>N limits display to alt chains with more than N blocks -N limits display to alt chains younger than N blocks
Diffstat (limited to 'src/daemon/command_parser_executor.cpp')
-rw-r--r--src/daemon/command_parser_executor.cpp31
1 files changed, 29 insertions, 2 deletions
diff --git a/src/daemon/command_parser_executor.cpp b/src/daemon/command_parser_executor.cpp
index 17b945c9a..a8a3db45a 100644
--- a/src/daemon/command_parser_executor.cpp
+++ b/src/daemon/command_parser_executor.cpp
@@ -672,11 +672,38 @@ bool t_command_parser_executor::alt_chain_info(const std::vector<std::string>& a
{
if(args.size() > 1)
{
- std::cout << "usage: alt_chain_info [block_hash]" << std::endl;
+ std::cout << "usage: alt_chain_info [block_hash|>N|-N]" << std::endl;
return false;
}
- return m_executor.alt_chain_info(args.size() == 1 ? args[0] : "");
+ std::string tip;
+ size_t above = 0;
+ uint64_t last_blocks = 0;
+ if (args.size() == 1)
+ {
+ if (args[0].size() > 0 && args[0][0] == '>')
+ {
+ if (!epee::string_tools::get_xtype_from_string(above, args[0].c_str() + 1))
+ {
+ std::cout << "invalid above parameter" << std::endl;
+ return false;
+ }
+ }
+ else if (args[0].size() > 0 && args[0][0] == '-')
+ {
+ if (!epee::string_tools::get_xtype_from_string(last_blocks, args[0].c_str() + 1))
+ {
+ std::cout << "invalid last_blocks parameter" << std::endl;
+ return false;
+ }
+ }
+ else
+ {
+ tip = args[0];
+ }
+ }
+
+ return m_executor.alt_chain_info(tip, above, last_blocks);
}
bool t_command_parser_executor::print_blockchain_dynamic_stats(const std::vector<std::string>& args)