daemon: allow printing N blocks from the end of the chain

It's a very common usage (for my anyway) and avoids the need to
get the current height, paste, subtract one, etc
This commit is contained in:
moneromooo-monero
2019-11-04 17:36:46 +00:00
parent ff94771b47
commit a633f85da9
3 changed files with 43 additions and 4 deletions

View File

@@ -154,6 +154,16 @@ bool t_command_parser_executor::print_blockchain_info(const std::vector<std::str
}
uint64_t start_index = 0;
uint64_t end_index = 0;
if (args[0][0] == '-')
{
int64_t nblocks;
if(!epee::string_tools::get_xtype_from_string(nblocks, args[0]))
{
std::cout << "wrong number of blocks" << std::endl;
return false;
}
return m_executor.print_blockchain_info(nblocks, (uint64_t)-nblocks);
}
if(!epee::string_tools::get_xtype_from_string(start_index, args[0]))
{
std::cout << "wrong starter block index parameter" << std::endl;