mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2024-11-23 11:23:26 +01:00
daemon: add a +hex option to print_block
This commit is contained in:
parent
ed54ac8fdf
commit
65ce387c93
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -91,9 +91,9 @@ public:
|
||||
|
||||
bool print_height();
|
||||
|
||||
bool print_block_by_hash(crypto::hash block_hash);
|
||||
bool print_block_by_hash(crypto::hash block_hash, bool include_hex);
|
||||
|
||||
bool print_block_by_height(uint64_t height);
|
||||
bool print_block_by_height(uint64_t height, bool include_hex);
|
||||
|
||||
bool print_transaction(crypto::hash transaction_hash, bool include_hex, bool include_json);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user