From 5a1ac9c0ef87f3f4fdc62a713d7336aa13211928 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Tue, 15 Dec 2020 20:26:09 +0000 Subject: rpc: add a busy_syncing field to get_info true if and pretty much only if new blocks are being added --- src/cryptonote_protocol/cryptonote_protocol_handler.h | 2 ++ src/cryptonote_protocol/cryptonote_protocol_handler.inl | 7 +++++++ 2 files changed, 9 insertions(+) (limited to 'src/cryptonote_protocol') diff --git a/src/cryptonote_protocol/cryptonote_protocol_handler.h b/src/cryptonote_protocol/cryptonote_protocol_handler.h index 6368f8190..8f867eee6 100644 --- a/src/cryptonote_protocol/cryptonote_protocol_handler.h +++ b/src/cryptonote_protocol/cryptonote_protocol_handler.h @@ -117,6 +117,8 @@ namespace cryptonote std::string get_peers_overview() const; std::pair get_next_needed_pruning_stripe() const; bool needs_new_sync_connections() const; + bool is_busy_syncing(); + private: //----------------- commands handlers ---------------------------------------------- int handle_notify_new_block(int command, NOTIFY_NEW_BLOCK::request& arg, cryptonote_connection_context& context); diff --git a/src/cryptonote_protocol/cryptonote_protocol_handler.inl b/src/cryptonote_protocol/cryptonote_protocol_handler.inl index 2df5b74a8..e2598e382 100644 --- a/src/cryptonote_protocol/cryptonote_protocol_handler.inl +++ b/src/cryptonote_protocol/cryptonote_protocol_handler.inl @@ -2771,6 +2771,13 @@ skip: } //------------------------------------------------------------------------------------------------------------------------ template + bool t_cryptonote_protocol_handler::is_busy_syncing() + { + const boost::unique_lock sync{m_sync_lock, boost::try_to_lock}; + return !sync.owns_lock(); + } + //------------------------------------------------------------------------------------------------------------------------ + template void t_cryptonote_protocol_handler::drop_connection_with_score(cryptonote_connection_context &context, unsigned score, bool flush_all_spans) { LOG_DEBUG_CC(context, "dropping connection id " << context.m_connection_id << " (pruning seed " << -- cgit v1.2.3