What changed, and why it matters
This commit simply deletes unused code from Monero's network synchronization module. It removes functions, macros, and declarations that were never called or had no definition. There is no change to active behavior, no bug fix, and no security-relevant change.
No security action needed. This is a routine code-cleanup commit with no functional or security impact.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit removes dead code in src/cryptonote_protocol/block_queue.cpp/h and cryptonote_protocol_handler.h/inl. Removed items include: block_queue::print(), get_num_filled_spans_prefix(), get_last_known_hash(), has_spans(), get_download_rate(), and the undeclared has_unpruned_height; plus get_synchronizing_connections_count(), PASSIVE_PEER_KICK_TIME, and LOCALHOST_INT. The commit message documents that each removed item had no live callers or was never defined. Stats: +0 -99 lines across 4 files.
Changed components
src/cryptonote_protocol/block_queue.cppsrc/cryptonote_protocol/block_queue.hsrc/cryptonote_protocol/cryptonote_protocol_handler.hsrc/cryptonote_protocol/cryptonote_protocol_handler.inlInspect captured patch +0 / −99
diff --git a/src/cryptonote_protocol/block_queue.cpp b/src/cryptonote_protocol/block_queue.cpp
index c564991..1b4accb 100644
--- a/src/cryptonote_protocol/block_queue.cpp
+++ b/src/cryptonote_protocol/block_queue.cpp
@@ -182,14 +182,6 @@ uint64_t block_queue::get_next_needed_height(uint64_t blockchain_height) const
return covered_until;
}
-void block_queue::print() const
-{
- boost::unique_lock<boost::recursive_mutex> lock(mutex);
- MDEBUG("Block queue has " << blocks.size() << " spans");
- for (const auto &span: blocks)
- MDEBUG(" " << span.start_block_height << " - " << (span.start_block_height+span.nblocks-1) << " (" << span.nblocks << ") - " << (span.blocks.empty() ? "scheduled" : "filled ") << " " << span.connection_id << " (" << ((unsigned)(span.rate*10/1024.f))/10.f << " kB/s)");
-}
-
std::string block_queue::get_overview(uint64_t blockchain_height) const
{
boost::unique_lock<boost::recursive_mutex> lock(mutex);
@@ -430,22 +422,6 @@ size_t block_queue::get_data_size() const
return size;
}
-size_t block_queue::get_num_filled_spans_prefix() const
-{
- boost::unique_lock<boost::recursive_mutex> lock(mutex);
-
- if (blocks.empty())
- return 0;
- block_map::const_iterator i = blocks.begin();
- size_t size = 0;
- while (i != blocks.end() && !i->blocks.empty())
- {
- ++i;
- ++size;
- }
- return size;
-}
-
size_t block_queue::get_num_filled_spans() const
{
boost::unique_lock<boost::recursive_mutex> lock(mutex);
@@ -456,35 +432,6 @@ size_t block_queue::get_num_filled_spans() const
return size;
}
-crypto::hash block_queue::get_last_known_hash(const boost::uuids::uuid &connection_id) const
-{
- boost::unique_lock<boost::recursive_mutex> lock(mutex);
- crypto::hash hash = crypto::null_hash;
- uint64_t highest_height = 0;
- for (const auto &span: blocks)
- {
- if (span.connection_id != connection_id)
- continue;
- uint64_t h = span.start_block_height + span.nblocks - 1;
- if (h > highest_height && span.hashes.size() == span.nblocks)
- {
- hash = span.hashes.back();
- highest_height = h;
- }
- }
- return hash;
-}
-
-bool block_queue::has_spans(const boost::uuids::uuid &connection_id) const
-{
- for (const auto &span: blocks)
- {
- if (span.connection_id == connection_id)
- return true;
- }
- return false;
-}
-
float block_queue::get_speed(const boost::uuids::uuid &connection_id) const
{
boost::unique_lock<boost::recursive_mutex> lock(mutex);
@@ -521,31 +468,6 @@ float block_queue::get_speed(const boost::uuids::uuid &connection_id) const
return speed;
}
-float block_queue::get_download_rate(const boost::uuids::uuid &connection_id) const
-{
- boost::unique_lock<boost::recursive_mutex> lock(mutex);
- float conn_rate = -1.f;
- for (const auto &span: blocks)
- {
- if (span.blocks.empty())
- continue;
- if (span.connection_id != connection_id)
- continue;
- // note that the average below does not average over the whole set, but over the
- // previous pseudo average and the latest rate: this gives much more importance
- // to the latest measurements, which is fine here
- if (conn_rate < 0.f)
- conn_rate = span.rate;
- else
- conn_rate = (conn_rate + span.rate) / 2;
- }
-
- if (conn_rate < 0)
- conn_rate = 0.0f;
- MTRACE("Download rate for " << connection_id << ": " << conn_rate << " b/s");
- return conn_rate;
-}
-
bool block_queue::foreach(std::function<bool(const span&)> f) const
{
boost::unique_lock<boost::recursive_mutex> lock(mutex);
diff --git a/src/cryptonote_protocol/block_queue.h b/src/cryptonote_protocol/block_queue.h
index 979cd1d..9e189da 100644
--- a/src/cryptonote_protocol/block_queue.h
+++ b/src/cryptonote_protocol/block_queue.h
@@ -78,9 +78,7 @@ namespace cryptonote
bool remove_span(uint64_t start_block_height, std::vector<crypto::hash> *hashes = NULL);
void remove_spans(const boost::uuids::uuid &connection_id, uint64_t start_block_height);
uint64_t get_max_block_height() const;
- void print() const;
std::string get_overview(uint64_t blockchain_height) const;
- bool has_unpruned_height(uint64_t block_height, uint64_t blockchain_height, uint32_t pruning_seed) const;
std::pair<uint64_t, uint64_t> reserve_span(uint64_t first_block_height, uint64_t last_block_height, uint64_t max_blocks, const boost::uuids::uuid &connection_id, const epee::net_utils::network_address &addr, bool sync_pruned_blocks, uint32_t local_pruning_seed, uint32_t pruning_seed, uint64_t blockchain_height, const std::vector<std::pair<crypto::hash, uint64_t>> &block_hashes, boost::posix_time::ptime time = boost::posix_time::microsec_clock::universal_time());
uint64_t get_next_needed_height(uint64_t blockchain_height) const;
std::pair<uint64_t, uint64_t> get_next_span_if_scheduled(std::vector<crypto::hash> &hashes, boost::uuids::uuid &connection_id, boost::posix_time::ptime &time) const;
@@ -90,12 +88,8 @@ namespace cryptonote
bool has_next_span(const boost::uuids::uuid &connection_id, bool &filled, boost::posix_time::ptime &time) const;
bool has_next_span(uint64_t height, bool &filled, boost::posix_time::ptime &time, boost::uuids::uuid &connection_id) const;
size_t get_data_size() const;
- size_t get_num_filled_spans_prefix() const;
size_t get_num_filled_spans() const;
- crypto::hash get_last_known_hash(const boost::uuids::uuid &connection_id) const;
- bool has_spans(const boost::uuids::uuid &connection_id) const;
float get_speed(const boost::uuids::uuid &connection_id) const;
- float get_download_rate(const boost::uuids::uuid &connection_id) const;
bool foreach(std::function<bool(const span&)> f) const;
bool requested(const crypto::hash &hash) const;
bool have(const crypto::hash &hash) const;
diff --git a/src/cryptonote_protocol/cryptonote_protocol_handler.h b/src/cryptonote_protocol/cryptonote_protocol_handler.h
index a7dc77c..9d4f8a2 100644
--- a/src/cryptonote_protocol/cryptonote_protocol_handler.h
+++ b/src/cryptonote_protocol/cryptonote_protocol_handler.h
@@ -55,7 +55,6 @@
PUSH_WARNINGS
DISABLE_VS_WARNINGS(4355)
-#define LOCALHOST_INT 2130706433
#define CURRENCY_PROTOCOL_MAX_OBJECT_REQUEST_COUNT 100
static_assert(CURRENCY_PROTOCOL_MAX_OBJECT_REQUEST_COUNT >= BLOCKS_SYNCHRONIZING_DEFAULT_COUNT_PRE_V4, "Invalid CURRENCY_PROTOCOL_MAX_OBJECT_REQUEST_COUNT");
@@ -164,7 +163,6 @@ namespace cryptonote
//bool get_payload_sync_data(HANDSHAKE_DATA::request& hshd, cryptonote_connection_context& context);
bool should_drop_connection(cryptonote_connection_context& context, uint32_t next_stripe);
bool request_missing_objects(cryptonote_connection_context& context, bool check_having_blocks, bool force_next_span = false);
- size_t get_synchronizing_connections_count();
bool on_connection_synchronized();
bool should_download_next_span(cryptonote_connection_context& context, bool standby);
bool should_ask_for_pruned_data(cryptonote_connection_context& context, uint64_t first_block_height, uint64_t nblocks, bool check_block_weights) const;
diff --git a/src/cryptonote_protocol/cryptonote_protocol_handler.inl b/src/cryptonote_protocol/cryptonote_protocol_handler.inl
index 23fdcca..bc841cf 100644
--- a/src/cryptonote_protocol/cryptonote_protocol_handler.inl
+++ b/src/cryptonote_protocol/cryptonote_protocol_handler.inl
@@ -77,7 +77,6 @@
#define REQUEST_NEXT_SCHEDULED_SPAN_THRESHOLD (30 * 1000000) // microseconds
#define IDLE_PEER_KICK_TIME (240 * 1000000) // microseconds
#define NON_RESPONSIVE_PEER_KICK_TIME (20 * 1000000) // microseconds
-#define PASSIVE_PEER_KICK_TIME (60 * 1000000) // microseconds
#define DROP_ON_SYNC_WEDGE_THRESHOLD (30 * 1000000000ull) // nanoseconds
#define LAST_ACTIVITY_STALL_THRESHOLD (2.0f) // seconds
#define DROP_PEERS_ON_SCORE -2
@@ -2476,18 +2475,6 @@ skip:
}
//------------------------------------------------------------------------------------------------------------------------
template<class t_core>
- size_t t_cryptonote_protocol_handler<t_core>::get_synchronizing_connections_count()
- {
- size_t count = 0;
- m_p2p->for_each_connection([&](cryptonote_connection_context& context, nodetool::peerid_type peer_id, uint32_t support_flags)->bool{
- if(context.m_state == cryptonote_connection_context::state_synchronizing)
- ++count;
- return true;
- });
- return count;
- }
- //------------------------------------------------------------------------------------------------------------------------
- template<class t_core>
int t_cryptonote_protocol_handler<t_core>::handle_response_chain_entry(int command, NOTIFY_RESPONSE_CHAIN_ENTRY::request& arg, cryptonote_connection_context& context)
{
MLOG_P2P_MESSAGE("Received NOTIFY_RESPONSE_CHAIN_ENTRY: m_block_ids.size()=" << arg.m_block_ids.size()
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.