aboutsummaryrefslogtreecommitdiff
path: root/src/daemon/command_parser_executor.cpp
diff options
context:
space:
mode:
authorJason Wong <jason.hcwong@gmail.com>2018-11-25 22:08:07 +0100
committerJason Wong <jason.hcwong@gmail.com>2018-11-28 12:20:28 +0100
commitdc1c12528d5cf86759993614e1fdd7d7bf04ff15 (patch)
tree8fa2119970bd01b384481d2944b1dc137f271435 /src/daemon/command_parser_executor.cpp
parentMerge pull request #4821 (diff)
downloadmonero-dc1c12528d5cf86759993614e1fdd7d7bf04ff15.tar.xz
add command pop_blocks
add new public method to Blockchain and update according to code review update after review: better lock/unlock, try catch and coding style
Diffstat (limited to 'src/daemon/command_parser_executor.cpp')
-rw-r--r--src/daemon/command_parser_executor.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/daemon/command_parser_executor.cpp b/src/daemon/command_parser_executor.cpp
index 1638cf505..853cde9c3 100644
--- a/src/daemon/command_parser_executor.cpp
+++ b/src/daemon/command_parser_executor.cpp
@@ -674,6 +674,31 @@ bool t_command_parser_executor::sync_info(const std::vector<std::string>& args)
return m_executor.sync_info();
}
+bool t_command_parser_executor::pop_blocks(const std::vector<std::string>& args)
+{
+ if (args.size() != 1)
+ {
+ std::cout << "Exactly one parameter is needed" << std::endl;
+ return false;
+ }
+
+ try
+ {
+ uint64_t nblocks = boost::lexical_cast<uint64_t>(args[0]);
+ if (nblocks < 1)
+ {
+ std::cout << "number of blocks must be greater than 0" << std::endl;
+ return false;
+ }
+ return m_executor.pop_blocks(nblocks);
+ }
+ catch (const boost::bad_lexical_cast&)
+ {
+ std::cout << "number of blocks must be a number greater than 0" << std::endl;
+ }
+ return false;
+}
+
bool t_command_parser_executor::version(const std::vector<std::string>& args)
{
std::cout << "Monero '" << MONERO_RELEASE_NAME << "' (v" << MONERO_VERSION_FULL << ")" << std::endl;