aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/cryptonote_core/blockchain.cpp7
-rw-r--r--src/cryptonote_core/blockchain.h5
-rw-r--r--src/cryptonote_core/cryptonote_core.cpp4
-rw-r--r--src/cryptonote_core/cryptonote_core.h5
-rw-r--r--src/daemon/command_parser_executor.cpp20
-rw-r--r--src/daemon/command_server.cpp2
-rw-r--r--src/daemon/rpc_command_executor.cpp3
-rw-r--r--src/daemon/rpc_command_executor.h2
-rw-r--r--src/rpc/core_rpc_server.cpp2
-rw-r--r--src/rpc/core_rpc_server_commands_defs.h2
10 files changed, 46 insertions, 6 deletions
diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp
index 78893fdf2..a8683a531 100644
--- a/src/cryptonote_core/blockchain.cpp
+++ b/src/cryptonote_core/blockchain.cpp
@@ -2541,6 +2541,13 @@ bool Blockchain::add_block_as_invalid(const block_extended_info& bei, const cryp
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
{
LOG_PRINT_L3("Blockchain::" << __func__);
diff --git a/src/cryptonote_core/blockchain.h b/src/cryptonote_core/blockchain.h
index 0aecdcb57..4ed7a2f02 100644
--- a/src/cryptonote_core/blockchain.h
+++ b/src/cryptonote_core/blockchain.h
@@ -1017,6 +1017,11 @@ namespace cryptonote
*/
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
private:
#endif
diff --git a/src/cryptonote_core/cryptonote_core.cpp b/src/cryptonote_core/cryptonote_core.cpp
index 5c8f59291..9cfa839b2 100644
--- a/src/cryptonote_core/cryptonote_core.cpp
+++ b/src/cryptonote_core/cryptonote_core.cpp
@@ -1942,6 +1942,10 @@ namespace cryptonote
bad_semantics_txes_lock.unlock();
}
//-----------------------------------------------------------------------------------------------
+ void core::flush_invalid_blocks()
+ {
+ m_blockchain_storage.flush_invalid_blocks();
+ }
bool core::update_blockchain_pruning()
{
return m_blockchain_storage.update_blockchain_pruning();
diff --git a/src/cryptonote_core/cryptonote_core.h b/src/cryptonote_core/cryptonote_core.h
index 55efb566c..16dd85003 100644
--- a/src/cryptonote_core/cryptonote_core.h
+++ b/src/cryptonote_core/cryptonote_core.h
@@ -859,6 +859,11 @@ namespace cryptonote
*/
void flush_bad_txs_cache();
+ /**
+ * @brief flushes the invalid block cache
+ */
+ void flush_invalid_blocks();
+
private:
/**
diff --git a/src/daemon/command_parser_executor.cpp b/src/daemon/command_parser_executor.cpp
index ed6d3af01..3a4081e39 100644
--- a/src/daemon/command_parser_executor.cpp
+++ b/src/daemon/command_parser_executor.cpp
@@ -857,13 +857,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 bad_txs = false, bad_blocks = false;
+ std::string arg;
+
if (args.empty())
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:
- 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;
}
diff --git a/src/daemon/command_server.cpp b/src/daemon/command_server.cpp
index 8ec690631..7fae77c30 100644
--- a/src/daemon/command_server.cpp
+++ b/src/daemon/command_server.cpp
@@ -325,7 +325,7 @@ t_command_server::t_command_server(
m_command_lookup.set_handler(
"flush_cache"
, 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)."
);
}
diff --git a/src/daemon/rpc_command_executor.cpp b/src/daemon/rpc_command_executor.cpp
index 1ca728e39..a8026ebf7 100644
--- a/src/daemon/rpc_command_executor.cpp
+++ b/src/daemon/rpc_command_executor.cpp
@@ -2427,7 +2427,7 @@ bool t_rpc_command_executor::set_bootstrap_daemon(
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::response res;
@@ -2435,6 +2435,7 @@ bool t_rpc_command_executor::flush_cache(bool bad_txs)
epee::json_rpc::error error_resp;
req.bad_txs = bad_txs;
+ req.bad_blocks = bad_blocks;
if (m_is_rpc)
{
diff --git a/src/daemon/rpc_command_executor.h b/src/daemon/rpc_command_executor.h
index 1754ce32e..66ada6f1f 100644
--- a/src/daemon/rpc_command_executor.h
+++ b/src/daemon/rpc_command_executor.h
@@ -172,7 +172,7 @@ public:
bool rpc_payments();
- bool flush_cache(bool bad_txs);
+ bool flush_cache(bool bad_txs, bool invalid_blocks);
};
} // namespace daemonize
diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp
index 409c8a01c..386ef66dc 100644
--- a/src/rpc/core_rpc_server.cpp
+++ b/src/rpc/core_rpc_server.cpp
@@ -3014,6 +3014,8 @@ namespace cryptonote
RPC_TRACKER(flush_cache);
if (req.bad_txs)
m_core.flush_bad_txs_cache();
+ if (req.bad_blocks)
+ m_core.flush_invalid_blocks();
res.status = CORE_RPC_STATUS_OK;
return true;
}
diff --git a/src/rpc/core_rpc_server_commands_defs.h b/src/rpc/core_rpc_server_commands_defs.h
index 12b042c7e..89e0a6726 100644
--- a/src/rpc/core_rpc_server_commands_defs.h
+++ b/src/rpc/core_rpc_server_commands_defs.h
@@ -2561,10 +2561,12 @@ namespace cryptonote
struct request_t: public rpc_request_base
{
bool bad_txs;
+ bool bad_blocks;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE_PARENT(rpc_request_base)
KV_SERIALIZE_OPT(bad_txs, false)
+ KV_SERIALIZE_OPT(bad_blocks, false)
END_KV_SERIALIZE_MAP()
};
typedef epee::misc_utils::struct_init<request_t> request;