Skip to content

Commit 72ac033

Browse files
authored
chore: Remove StorageStats (#283)
1 parent 84a9552 commit 72ac033

File tree

4 files changed

+1
-67
lines changed

4 files changed

+1
-67
lines changed

dash-spv/src/storage/mod.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,6 @@ pub trait StorageManager: Send + Sync {
157157
/// Clear all filter headers and compact filters.
158158
async fn clear_filters(&mut self) -> StorageResult<()>;
159159

160-
/// Get storage statistics.
161-
async fn stats(&self) -> StorageResult<StorageStats>;
162-
163160
/// Get header height by block hash (reverse lookup).
164161
async fn get_header_height_by_hash(
165162
&self,

dash-spv/src/storage/state.rs

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use dashcore_hashes::Hash;
99

1010
use crate::error::StorageResult;
1111
use crate::storage::manager::WorkerCommand;
12-
use crate::storage::{MasternodeState, StorageManager, StorageStats};
12+
use crate::storage::{MasternodeState, StorageManager};
1313
use crate::types::{ChainState, MempoolState, UnconfirmedTransaction};
1414

1515
use super::io::atomic_write;
@@ -268,40 +268,6 @@ impl DiskStorageManager {
268268
Ok(())
269269
}
270270

271-
/// Get storage statistics.
272-
pub async fn stats(&self) -> StorageResult<StorageStats> {
273-
let mut component_sizes = HashMap::new();
274-
let mut total_size = 0u64;
275-
276-
// Calculate directory sizes
277-
if let Ok(mut entries) = tokio::fs::read_dir(&self.base_path).await {
278-
while let Ok(Some(entry)) = entries.next_entry().await {
279-
if let Ok(metadata) = entry.metadata().await {
280-
if metadata.is_file() {
281-
total_size += metadata.len();
282-
}
283-
}
284-
}
285-
}
286-
287-
let header_count = self.block_headers.read().await.tip_height().map_or(0, |h| h as u64 + 1);
288-
let filter_header_count =
289-
self.filter_headers.read().await.tip_height().map_or(0, |h| h as u64 + 1);
290-
291-
component_sizes.insert("headers".to_string(), header_count * 80);
292-
component_sizes.insert("filter_headers".to_string(), filter_header_count * 32);
293-
component_sizes
294-
.insert("index".to_string(), self.header_hash_index.read().await.len() as u64 * 40);
295-
296-
Ok(StorageStats {
297-
header_count,
298-
filter_header_count,
299-
filter_count: 0, // TODO: Count filter files
300-
total_size,
301-
component_sizes,
302-
})
303-
}
304-
305271
/// Shutdown the storage manager.
306272
pub async fn shutdown(&mut self) {
307273
// Persist all dirty data
@@ -503,10 +469,6 @@ impl StorageManager for DiskStorageManager {
503469
Ok(())
504470
}
505471

506-
async fn stats(&self) -> StorageResult<StorageStats> {
507-
Self::stats(self).await
508-
}
509-
510472
async fn get_header_height_by_hash(&self, hash: &BlockHash) -> StorageResult<Option<u32>> {
511473
Self::get_header_height_by_hash(self, hash).await
512474
}

dash-spv/src/storage/types.rs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//! Storage-related types and structures.
22
33
use serde::{Deserialize, Serialize};
4-
use std::collections::HashMap;
54

65
/// Masternode state for storage.
76
#[derive(Debug, Clone, Serialize, Deserialize)]
@@ -15,22 +14,3 @@ pub struct MasternodeState {
1514
/// Last update timestamp.
1615
pub last_update: u64,
1716
}
18-
19-
/// Storage statistics.
20-
#[derive(Debug, Clone, Default)]
21-
pub struct StorageStats {
22-
/// Number of headers stored.
23-
pub header_count: u64,
24-
25-
/// Number of filter headers stored.
26-
pub filter_header_count: u64,
27-
28-
/// Number of filters stored.
29-
pub filter_count: u64,
30-
31-
/// Total storage size in bytes.
32-
pub total_size: u64,
33-
34-
/// Individual component sizes.
35-
pub component_sizes: HashMap<String, u64>,
36-
}

dash-spv/tests/segmented_storage_test.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -324,11 +324,6 @@ async fn test_mixed_operations() {
324324

325325
assert_eq!(storage.load_metadata("test_key").await.unwrap().unwrap(), b"test_value");
326326

327-
// Get stats
328-
let stats = storage.stats().await.unwrap();
329-
assert_eq!(stats.header_count, 75_000);
330-
assert_eq!(stats.filter_header_count, 75_000);
331-
332327
storage.shutdown().await;
333328
}
334329

0 commit comments

Comments
 (0)