rpc: add a flush_cache RPC

This allows flushing internal caches (for now, the bad tx cache,
which will allow debugging a stuck monerod after it has failed to
verify a transaction in a block, since it would otherwise not try
again, making subsequent log changes pointless)
This commit is contained in:
moneromooo-monero
2019-10-22 15:28:08 +00:00
parent 960c215801
commit a4dc575ccb
11 changed files with 103 additions and 7 deletions

View File

@@ -2373,6 +2373,34 @@ bool t_rpc_command_executor::set_bootstrap_daemon(
return true;
}
bool t_rpc_command_executor::flush_cache(bool bad_txs)
{
cryptonote::COMMAND_RPC_FLUSH_CACHE::request req;
cryptonote::COMMAND_RPC_FLUSH_CACHE::response res;
std::string fail_message = "Unsuccessful";
epee::json_rpc::error error_resp;
req.bad_txs = bad_txs;
if (m_is_rpc)
{
if (!m_rpc_client->json_rpc_request(req, res, "flush_cache", fail_message.c_str()))
{
return true;
}
}
else
{
if (!m_rpc_server->on_flush_cache(req, res, error_resp) || res.status != CORE_RPC_STATUS_OK)
{
tools::fail_msg_writer() << make_error(fail_message, res.status);
return true;
}
}
return true;
}
bool t_rpc_command_executor::rpc_payments()
{
cryptonote::COMMAND_RPC_ACCESS_DATA::request req;