aboutsummaryrefslogtreecommitdiff
path: root/src/daemon/rpc_command_executor.cpp
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2018-12-12 11:58:36 +0200
committerRiccardo Spagni <ric@spagni.net>2018-12-12 11:58:37 +0200
commit0fccc78e3966477309cb4e9c037c0a9f004ea99e (patch)
tree5ec83c8705bc716c5efd497b85069e256a5401d8 /src/daemon/rpc_command_executor.cpp
parentMerge pull request #4901 (diff)
parentadd command pop_blocks (diff)
downloadmonero-0fccc78e3966477309cb4e9c037c0a9f004ea99e.tar.xz
Merge pull request #4903
dc1c1252 add command pop_blocks (Jason Wong)
Diffstat (limited to 'src/daemon/rpc_command_executor.cpp')
-rw-r--r--src/daemon/rpc_command_executor.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/daemon/rpc_command_executor.cpp b/src/daemon/rpc_command_executor.cpp
index 5ae9851a7..015e1e1f9 100644
--- a/src/daemon/rpc_command_executor.cpp
+++ b/src/daemon/rpc_command_executor.cpp
@@ -1967,4 +1967,31 @@ bool t_rpc_command_executor::sync_info()
return true;
}
+bool t_rpc_command_executor::pop_blocks(uint64_t num_blocks)
+{
+ cryptonote::COMMAND_RPC_POP_BLOCKS::request req;
+ cryptonote::COMMAND_RPC_POP_BLOCKS::response res;
+ std::string fail_message = "pop_blocks failed";
+
+ req.nblocks = num_blocks;
+ if (m_is_rpc)
+ {
+ if (!m_rpc_client->rpc_request(req, res, "/pop_blocks", fail_message.c_str()))
+ {
+ return true;
+ }
+ }
+ else
+ {
+ if (!m_rpc_server->on_pop_blocks(req, res) || res.status != CORE_RPC_STATUS_OK)
+ {
+ tools::fail_msg_writer() << make_error(fail_message, res.status);
+ return true;
+ }
+ }
+ tools::success_msg_writer() << "new height: " << res.height;
+
+ return true;
+}
+
}// namespace daemonize