daemon: add a +hex option to print_block

This commit is contained in:
moneromooo-monero 2018-12-26 17:55:04 +00:00
parent ed54ac8fdf
commit 65ce387c93
No known key found for this signature in database
GPG key ID: 686F07454D6CEFC3
3 changed files with 23 additions and 7 deletions

View file

@ -663,7 +663,7 @@ bool t_rpc_command_executor::print_height() {
return true;
}
bool t_rpc_command_executor::print_block_by_hash(crypto::hash block_hash) {
bool t_rpc_command_executor::print_block_by_hash(crypto::hash block_hash, bool include_hex) {
cryptonote::COMMAND_RPC_GET_BLOCK::request req;
cryptonote::COMMAND_RPC_GET_BLOCK::response res;
epee::json_rpc::error error_resp;
@ -689,13 +689,15 @@ bool t_rpc_command_executor::print_block_by_hash(crypto::hash block_hash) {
}
}
if (include_hex)
tools::success_msg_writer() << res.blob << std::endl;
print_block_header(res.block_header);
tools::success_msg_writer() << res.json << ENDL;
return true;
}
bool t_rpc_command_executor::print_block_by_height(uint64_t height) {
bool t_rpc_command_executor::print_block_by_height(uint64_t height, bool include_hex) {
cryptonote::COMMAND_RPC_GET_BLOCK::request req;
cryptonote::COMMAND_RPC_GET_BLOCK::response res;
epee::json_rpc::error error_resp;
@ -721,6 +723,8 @@ bool t_rpc_command_executor::print_block_by_height(uint64_t height) {
}
}
if (include_hex)
tools::success_msg_writer() << res.blob << std::endl;
print_block_header(res.block_header);
tools::success_msg_writer() << res.json << ENDL;