diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2018-12-26 17:55:04 +0000 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2018-12-26 17:55:28 +0000 |
commit | 65ce387c93affd087bc6220d5748e63c8853d7ab (patch) | |
tree | 9a95f1e9ef3733633f369c7c2e5c392e7c79c6d0 /src/daemon/command_parser_executor.cpp | |
parent | Merge pull request #4902 (diff) | |
download | monero-65ce387c93affd087bc6220d5748e63c8853d7ab.tar.xz |
daemon: add a +hex option to print_block
Diffstat (limited to '')
-rw-r--r-- | src/daemon/command_parser_executor.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
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<std::string>& arg bool t_command_parser_executor::print_block(const std::vector<std::string>& args) { + bool include_hex = false; + + // Assumes that optional flags come after mandatory argument <transaction_hash> + 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 (<block_hash> | <block_height>)" << std::endl; + std::cout << "expected: print_block (<block_hash> | <block_height>) [+hex]" << std::endl; return false; } @@ -173,14 +185,14 @@ bool t_command_parser_executor::print_block(const std::vector<std::string>& args try { uint64_t height = boost::lexical_cast<uint64_t>(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); } } |