mirror of
https://github.com/monero-project/monero.git
synced 2025-07-25 10:15:21 -04:00
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
This commit is contained in:
parent
58ce16d4d9
commit
dc1c12528d
10 changed files with 138 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue