Skip to content

Commit 38fce8e

Browse files
fix: update filter header height retrieval to use storage directly
1 parent e07ba92 commit 38fce8e

File tree

1 file changed

+15
-20
lines changed

1 file changed

+15
-20
lines changed

dash-spv/src/client/status_display.rs

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,11 @@ impl<'a, S: StorageManager + Send + Sync + 'static> StatusDisplay<'a, S> {
8585
// Calculate the actual header height considering checkpoint sync
8686
let header_height = self.calculate_header_height(&state).await;
8787

88-
// Calculate filter header height considering checkpoint sync
89-
let filter_header_height = self.calculate_filter_header_height().await;
88+
// Get filter header height from storage
89+
let storage = self.storage.lock().await;
90+
let filter_header_height = storage.get_filter_tip_height().await
91+
.ok().flatten().unwrap_or(0);
92+
drop(storage);
9093

9194
Ok(SyncProgress {
9295
header_height,
@@ -125,8 +128,11 @@ impl<'a, S: StorageManager + Send + Sync + 'static> StatusDisplay<'a, S> {
125128
self.calculate_header_height_with_logging(&state, true).await
126129
};
127130

128-
// Get filter header height - convert from storage height to blockchain height
129-
let filter_height = self.calculate_filter_header_height().await;
131+
// Get filter header height from storage
132+
let storage = self.storage.lock().await;
133+
let filter_height = storage.get_filter_tip_height().await
134+
.ok().flatten().unwrap_or(0);
135+
drop(storage);
130136

131137
// Get latest chainlock height from state
132138
let chainlock_height = {
@@ -174,8 +180,11 @@ impl<'a, S: StorageManager + Send + Sync + 'static> StatusDisplay<'a, S> {
174180
self.calculate_header_height_with_logging(&state, true).await
175181
};
176182

177-
// Get filter header height - convert from storage height to blockchain height
178-
let filter_height = self.calculate_filter_header_height().await;
183+
// Get filter header height from storage
184+
let storage = self.storage.lock().await;
185+
let filter_height = storage.get_filter_tip_height().await
186+
.ok().flatten().unwrap_or(0);
187+
drop(storage);
179188

180189
let chainlock_height = {
181190
let state = self.state.read().await;
@@ -205,18 +214,4 @@ impl<'a, S: StorageManager + Send + Sync + 'static> StatusDisplay<'a, S> {
205214
}
206215
}
207216

208-
/// Calculate the filter header height considering checkpoint sync.
209-
///
210-
/// This helper method encapsulates the logic for determining the current filter header height.
211-
/// Note: get_filter_tip_height() now returns absolute blockchain height directly.
212-
async fn calculate_filter_header_height(&self) -> u32 {
213-
let storage = self.storage.lock().await;
214-
if let Ok(Some(filter_tip)) = storage.get_filter_tip_height().await {
215-
// The storage now returns absolute blockchain height directly
216-
filter_tip
217-
} else {
218-
// No filter headers in storage yet
219-
0
220-
}
221-
}
222217
}

0 commit comments

Comments
 (0)