From 65ce387c93affd087bc6220d5748e63c8853d7ab Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Wed, 26 Dec 2018 17:55:04 +0000 Subject: daemon: add a +hex option to print_block --- src/daemon/command_parser_executor.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'src/daemon/command_parser_executor.cpp') diff --git a/src/daemon/command_parser_executor.cpp b/src/daemon/command_parser_executor.cpp index 853cde9c3..b5b747e97 100644 --- a/src/daemon/command_parser_executor.cpp +++ b/src/daemon/command_parser_executor.cpp @@ -163,9 +163,21 @@ bool t_command_parser_executor::print_height(const std::vector& arg bool t_command_parser_executor::print_block(const std::vector& args) { + bool include_hex = false; + + // Assumes that optional flags come after mandatory argument + for (unsigned int i = 1; i < args.size(); ++i) { + if (args[i] == "+hex") + include_hex = true; + else + { + std::cout << "unexpected argument: " << args[i] << std::endl; + return true; + } + } if (args.empty()) { - std::cout << "expected: print_block ( | )" << std::endl; + std::cout << "expected: print_block ( | ) [+hex]" << std::endl; return false; } @@ -173,14 +185,14 @@ bool t_command_parser_executor::print_block(const std::vector& args try { uint64_t height = boost::lexical_cast(arg); - return m_executor.print_block_by_height(height); + return m_executor.print_block_by_height(height, include_hex); } catch (const boost::bad_lexical_cast&) { crypto::hash block_hash; if (parse_hash256(arg, block_hash)) { - return m_executor.print_block_by_hash(block_hash); + return m_executor.print_block_by_hash(block_hash, include_hex); } } -- cgit v1.2.3