Skip to content

Commit 0b53a19

Browse files
refactor: fix warnings in dash spv (#110)
* fix: remove dead code and fix warnings (89% reduction: 76→8 warnings) This commit addresses dead code warnings and other compiler warnings across the dash-spv crate, reducing total warnings from 76 to 8 (89% reduction). ## Dead Code Removed: - client/mod.rs: 12 unused methods (handle_inventory, process_new_headers, etc.) - client/filter_sync.rs: 1 unused method (find_height_for_block_hash) - client/message_handler.rs: 1 unused field (filter_processor) + constructor updates - network/mod.rs: 1 unused field (message_receiver) + constructor updates - network/multi_peer.rs: 2 unused methods (select_peer, send_to_peer) - sync/chainlock_validation.rs: 1 unused method (find_chain_lock_quorum) - sync/filters.rs: 4 unused constants + 3 unused fields + constructor fixes ## Other Fixes: - Removed 2 unused imports (FilterNotificationSender, BLSPublicKey) - Fixed private interface: made ChainLockStats public - Updated method calls and constructors to remove unused parameters ## Files Modified: - dash-spv/src/client/filter_sync.rs: removed unused method - dash-spv/src/client/message_handler.rs: removed unused field and import - dash-spv/src/client/mod.rs: removed 12 unused methods - dash-spv/src/network/mod.rs: removed unused field - dash-spv/src/network/multi_peer.rs: removed 2 unused methods - dash-spv/src/sync/chainlock_validation.rs: removed unused method, fixed visibility - dash-spv/src/sync/filters.rs: removed unused constants and fields 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * fix: complete dead code cleanup and resolve import warnings (92% reduction: 76→6 warnings) This commit completes the systematic cleanup of compiler warnings in dash-spv: ### Fixed Issues: - **Unused imports**: Removed ForkDetectionResult, ReorgManager, ValidationManager - **Dead code cleanup**: Removed entire SyncStorageAdapter struct and implementation - **Unused struct fields**: Added #[allow(dead_code)] annotations for RecoveryEvent fields - **Unused enum variants**: Added #[allow(dead_code)] for ValidationCacheKey::ChainLock - **Orphaned code**: Cleaned up remaining code fragments from previous method removals ### Files Modified: - client/mod.rs: Removed duplicate find_height_for_block_hash method - headers_with_reorg.rs: Major cleanup - removed unused imports, SyncStorageAdapter, tests - recovery.rs: Added dead_code annotations for unused but intentional fields - validation.rs: Added dead_code annotation for ChainLock cache key ### Warning Reduction: - **Before**: 76 warnings (52 deprecated + 24 dead code) - **After**: 6 warnings (unused variables in stub methods) - **Improvement**: 92% reduction in compiler warnings ### Remaining Warnings: - 3 unused parameters in stub methods (intentional - methods kept for interface compatibility) - 3 unused methods in client and headers modules (future functionality) The project now builds cleanly with significantly reduced noise from compiler warnings, making genuine issues more visible to developers. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * refactor: more warnings resolved * refactor: simplify error handling and improve code readability * chore: run cargo fmt --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 547b356 commit 0b53a19

File tree

16 files changed

+94
-1359
lines changed

16 files changed

+94
-1359
lines changed

dash-spv/src/client/filter_sync.rs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
//! Filter synchronization and management for the Dash SPV client.
22
3-
#![allow(deprecated)]
4-
53
use std::sync::Arc;
64
use tokio::sync::RwLock;
75

86
use crate::error::{Result, SpvError};
97
use crate::network::NetworkManager;
108
use crate::storage::StorageManager;
11-
use crate::sync::SyncManager;
9+
use crate::sync::sequential::SequentialSyncManager;
1210
use crate::types::SpvStats;
1311
use crate::types::{FilterMatch, WatchItem};
1412

1513
/// Filter synchronization manager for coordinating filter downloads and checking.
1614
pub struct FilterSyncCoordinator<'a, S: StorageManager, N: NetworkManager> {
17-
sync_manager: &'a mut SyncManager<S, N>,
15+
sync_manager: &'a mut SequentialSyncManager<S, N>,
1816
storage: &'a mut S,
1917
network: &'a mut N,
2018
watch_items: &'a Arc<RwLock<std::collections::HashSet<WatchItem>>>,
@@ -27,7 +25,7 @@ impl<'a, S: StorageManager + Send + Sync + 'static, N: NetworkManager + Send + S
2725
{
2826
/// Create a new filter sync coordinator.
2927
pub fn new(
30-
sync_manager: &'a mut SyncManager<S, N>,
28+
sync_manager: &'a mut SequentialSyncManager<S, N>,
3129
storage: &'a mut S,
3230
network: &'a mut N,
3331
watch_items: &'a Arc<RwLock<std::collections::HashSet<WatchItem>>>,
@@ -165,10 +163,4 @@ impl<'a, S: StorageManager + Send + Sync + 'static, N: NetworkManager + Send + S
165163
let watch_items = self.watch_items.read().await;
166164
watch_items.iter().cloned().collect()
167165
}
168-
169-
/// Helper method to find height for a block hash.
170-
async fn find_height_for_block_hash(&self, block_hash: dashcore::BlockHash) -> Option<u32> {
171-
// Use the efficient reverse index
172-
self.storage.get_header_height_by_hash(&block_hash).await.ok().flatten()
173-
}
174166
}

dash-spv/src/client/message_handler.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use crate::error::{Result, SpvError};
88
use crate::mempool_filter::MempoolFilter;
99
use crate::network::NetworkManager;
1010
use crate::storage::StorageManager;
11-
use crate::sync::filters::FilterNotificationSender;
1211
use crate::sync::sequential::SequentialSyncManager;
1312
use crate::types::{MempoolState, SpvEvent, SpvStats};
1413

@@ -19,7 +18,6 @@ pub struct MessageHandler<'a, S: StorageManager, N: NetworkManager> {
1918
network: &'a mut N,
2019
config: &'a ClientConfig,
2120
stats: &'a Arc<RwLock<SpvStats>>,
22-
filter_processor: &'a Option<FilterNotificationSender>,
2321
block_processor_tx: &'a tokio::sync::mpsc::UnboundedSender<crate::client::BlockProcessingTask>,
2422
mempool_filter: &'a Option<Arc<MempoolFilter>>,
2523
mempool_state: &'a Arc<RwLock<MempoolState>>,
@@ -36,7 +34,6 @@ impl<'a, S: StorageManager + Send + Sync + 'static, N: NetworkManager + Send + S
3634
network: &'a mut N,
3735
config: &'a ClientConfig,
3836
stats: &'a Arc<RwLock<SpvStats>>,
39-
filter_processor: &'a Option<FilterNotificationSender>,
4037
block_processor_tx: &'a tokio::sync::mpsc::UnboundedSender<
4138
crate::client::BlockProcessingTask,
4239
>,
@@ -50,7 +47,6 @@ impl<'a, S: StorageManager + Send + Sync + 'static, N: NetworkManager + Send + S
5047
network,
5148
config,
5249
stats,
53-
filter_processor,
5450
block_processor_tx,
5551
mempool_filter,
5652
mempool_state,

0 commit comments

Comments
 (0)