mirror of
https://git.wownero.com/wownero/wownero.git
synced 2024-08-15 01:03:23 +00:00
rpc: add bad-blocks to flush_cache RPC
Flushes m_invalid_blocks in Blockchain.
This commit is contained in:
parent
411f1b0ee3
commit
5985c5afe8
10 changed files with 47 additions and 7 deletions
|
@ -2534,6 +2534,13 @@ bool Blockchain::add_block_as_invalid(const block_extended_info& bei, const cryp
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
|
void Blockchain::flush_invalid_blocks()
|
||||||
|
{
|
||||||
|
LOG_PRINT_L3("Blockchain::" << __func__);
|
||||||
|
CRITICAL_REGION_LOCAL(m_blockchain_lock);
|
||||||
|
m_invalid_blocks.clear();
|
||||||
|
}
|
||||||
|
//------------------------------------------------------------------
|
||||||
bool Blockchain::have_block(const crypto::hash& id) const
|
bool Blockchain::have_block(const crypto::hash& id) const
|
||||||
{
|
{
|
||||||
LOG_PRINT_L3("Blockchain::" << __func__);
|
LOG_PRINT_L3("Blockchain::" << __func__);
|
||||||
|
|
|
@ -1016,6 +1016,11 @@ namespace cryptonote
|
||||||
*/
|
*/
|
||||||
bool has_block_weights(uint64_t height, uint64_t nblocks) const;
|
bool has_block_weights(uint64_t height, uint64_t nblocks) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief flush the invalid blocks set
|
||||||
|
*/
|
||||||
|
void flush_invalid_blocks();
|
||||||
|
|
||||||
#ifndef IN_UNIT_TESTS
|
#ifndef IN_UNIT_TESTS
|
||||||
private:
|
private:
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1921,6 +1921,10 @@ namespace cryptonote
|
||||||
bad_semantics_txes_lock.unlock();
|
bad_semantics_txes_lock.unlock();
|
||||||
}
|
}
|
||||||
//-----------------------------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------------------------
|
||||||
|
void core::flush_invalid_blocks()
|
||||||
|
{
|
||||||
|
m_blockchain_storage.flush_invalid_blocks();
|
||||||
|
}
|
||||||
bool core::update_blockchain_pruning()
|
bool core::update_blockchain_pruning()
|
||||||
{
|
{
|
||||||
return m_blockchain_storage.update_blockchain_pruning();
|
return m_blockchain_storage.update_blockchain_pruning();
|
||||||
|
|
|
@ -844,6 +844,11 @@ namespace cryptonote
|
||||||
*/
|
*/
|
||||||
void flush_bad_txs_cache();
|
void flush_bad_txs_cache();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief flushes the invalid block cache
|
||||||
|
*/
|
||||||
|
void flush_invalid_blocks();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -846,13 +846,27 @@ bool t_command_parser_executor::set_bootstrap_daemon(const std::vector<std::stri
|
||||||
|
|
||||||
bool t_command_parser_executor::flush_cache(const std::vector<std::string>& args)
|
bool t_command_parser_executor::flush_cache(const std::vector<std::string>& args)
|
||||||
{
|
{
|
||||||
|
bool bad_txs = false, bad_blocks = false;
|
||||||
|
std::string arg;
|
||||||
|
|
||||||
if (args.empty())
|
if (args.empty())
|
||||||
goto show_list;
|
goto show_list;
|
||||||
if (args[0] == "bad-txs")
|
|
||||||
return m_executor.flush_cache(true);
|
for (size_t i = 0; i < args.size(); ++i)
|
||||||
|
{
|
||||||
|
arg = args[i];
|
||||||
|
if (arg == "bad-txs")
|
||||||
|
bad_txs = true;
|
||||||
|
else if (arg == "bad-blocks")
|
||||||
|
bad_blocks = true;
|
||||||
|
else
|
||||||
|
goto show_list;
|
||||||
|
}
|
||||||
|
return m_executor.flush_cache(bad_txs, bad_blocks);
|
||||||
|
|
||||||
show_list:
|
show_list:
|
||||||
std::cout << "Cache type needed: bad-txs" << std::endl;
|
std::cout << "Invalid cache type: " << arg << std::endl;
|
||||||
|
std::cout << "Cache types: bad-txs bad-blocks" << std::endl;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -325,7 +325,7 @@ t_command_server::t_command_server(
|
||||||
m_command_lookup.set_handler(
|
m_command_lookup.set_handler(
|
||||||
"flush_cache"
|
"flush_cache"
|
||||||
, std::bind(&t_command_parser_executor::flush_cache, &m_parser, p::_1)
|
, std::bind(&t_command_parser_executor::flush_cache, &m_parser, p::_1)
|
||||||
, "flush_cache bad-txs"
|
, "flush_cache [bad-txs] [bad-blocks]"
|
||||||
, "Flush the specified cache(s)."
|
, "Flush the specified cache(s)."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2373,7 +2373,7 @@ bool t_rpc_command_executor::set_bootstrap_daemon(
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool t_rpc_command_executor::flush_cache(bool bad_txs)
|
bool t_rpc_command_executor::flush_cache(bool bad_txs, bool bad_blocks)
|
||||||
{
|
{
|
||||||
cryptonote::COMMAND_RPC_FLUSH_CACHE::request req;
|
cryptonote::COMMAND_RPC_FLUSH_CACHE::request req;
|
||||||
cryptonote::COMMAND_RPC_FLUSH_CACHE::response res;
|
cryptonote::COMMAND_RPC_FLUSH_CACHE::response res;
|
||||||
|
@ -2381,6 +2381,7 @@ bool t_rpc_command_executor::flush_cache(bool bad_txs)
|
||||||
epee::json_rpc::error error_resp;
|
epee::json_rpc::error error_resp;
|
||||||
|
|
||||||
req.bad_txs = bad_txs;
|
req.bad_txs = bad_txs;
|
||||||
|
req.bad_blocks = bad_blocks;
|
||||||
|
|
||||||
if (m_is_rpc)
|
if (m_is_rpc)
|
||||||
{
|
{
|
||||||
|
|
|
@ -170,7 +170,7 @@ public:
|
||||||
|
|
||||||
bool rpc_payments();
|
bool rpc_payments();
|
||||||
|
|
||||||
bool flush_cache(bool bad_txs);
|
bool flush_cache(bool bad_txs, bool invalid_blocks);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace daemonize
|
} // namespace daemonize
|
||||||
|
|
|
@ -3004,6 +3004,8 @@ namespace cryptonote
|
||||||
RPC_TRACKER(flush_cache);
|
RPC_TRACKER(flush_cache);
|
||||||
if (req.bad_txs)
|
if (req.bad_txs)
|
||||||
m_core.flush_bad_txs_cache();
|
m_core.flush_bad_txs_cache();
|
||||||
|
if (req.bad_blocks)
|
||||||
|
m_core.flush_invalid_blocks();
|
||||||
res.status = CORE_RPC_STATUS_OK;
|
res.status = CORE_RPC_STATUS_OK;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,7 +88,7 @@ namespace cryptonote
|
||||||
// advance which version they will stop working with
|
// advance which version they will stop working with
|
||||||
// Don't go over 32767 for any of these
|
// Don't go over 32767 for any of these
|
||||||
#define CORE_RPC_VERSION_MAJOR 3
|
#define CORE_RPC_VERSION_MAJOR 3
|
||||||
#define CORE_RPC_VERSION_MINOR 0
|
#define CORE_RPC_VERSION_MINOR 1
|
||||||
#define MAKE_CORE_RPC_VERSION(major,minor) (((major)<<16)|(minor))
|
#define MAKE_CORE_RPC_VERSION(major,minor) (((major)<<16)|(minor))
|
||||||
#define CORE_RPC_VERSION MAKE_CORE_RPC_VERSION(CORE_RPC_VERSION_MAJOR, CORE_RPC_VERSION_MINOR)
|
#define CORE_RPC_VERSION MAKE_CORE_RPC_VERSION(CORE_RPC_VERSION_MAJOR, CORE_RPC_VERSION_MINOR)
|
||||||
|
|
||||||
|
@ -2559,9 +2559,11 @@ namespace cryptonote
|
||||||
struct request_t
|
struct request_t
|
||||||
{
|
{
|
||||||
bool bad_txs;
|
bool bad_txs;
|
||||||
|
bool bad_blocks;
|
||||||
|
|
||||||
BEGIN_KV_SERIALIZE_MAP()
|
BEGIN_KV_SERIALIZE_MAP()
|
||||||
KV_SERIALIZE_OPT(bad_txs, false)
|
KV_SERIALIZE_OPT(bad_txs, false)
|
||||||
|
KV_SERIALIZE_OPT(bad_blocks, false)
|
||||||
END_KV_SERIALIZE_MAP()
|
END_KV_SERIALIZE_MAP()
|
||||||
};
|
};
|
||||||
typedef epee::misc_utils::struct_init<request_t> request;
|
typedef epee::misc_utils::struct_init<request_t> request;
|
||||||
|
|
Loading…
Reference in a new issue