@@ -284,7 +284,8 @@ impl DiskStorageManager {
284284 tracing:: info!( "Index file not found, rebuilding from segments..." ) ;
285285
286286 // Load chain state to get sync_base_height for proper height calculation
287- let sync_base_height = if let Ok ( Some ( chain_state) ) = self . load_chain_state ( ) . await {
287+ let sync_base_height = if let Ok ( Some ( chain_state) ) = self . load_chain_state ( ) . await
288+ {
288289 chain_state. sync_base_height
289290 } else {
290291 0 // Assume genesis sync if no chain state
@@ -1200,8 +1201,11 @@ impl StorageManager for DiskStorageManager {
12001201 next_blockchain_height - sync_base_height
12011202 } else {
12021203 // This shouldn't happen in normal operation
1203- tracing:: warn!( "Attempting to store filter header at height {} below sync_base_height {}" ,
1204- next_blockchain_height, sync_base_height) ;
1204+ tracing:: warn!(
1205+ "Attempting to store filter header at height {} below sync_base_height {}" ,
1206+ next_blockchain_height,
1207+ sync_base_height
1208+ ) ;
12051209 next_blockchain_height
12061210 }
12071211 } else {
@@ -1296,7 +1300,10 @@ impl StorageManager for DiskStorageManager {
12961300 Ok ( filter_headers)
12971301 }
12981302
1299- async fn get_filter_header ( & self , blockchain_height : u32 ) -> StorageResult < Option < FilterHeader > > {
1303+ async fn get_filter_header (
1304+ & self ,
1305+ blockchain_height : u32 ,
1306+ ) -> StorageResult < Option < FilterHeader > > {
13001307 let sync_base_height = * self . sync_base_height . read ( ) . await ;
13011308
13021309 // Convert blockchain height to storage index
@@ -1306,8 +1313,11 @@ impl StorageManager for DiskStorageManager {
13061313 blockchain_height - sync_base_height
13071314 } else {
13081315 // This shouldn't happen in normal operation, but handle it gracefully
1309- tracing:: warn!( "Attempting to get filter header at height {} below sync_base_height {}" ,
1310- blockchain_height, sync_base_height) ;
1316+ tracing:: warn!(
1317+ "Attempting to get filter header at height {} below sync_base_height {}" ,
1318+ blockchain_height,
1319+ sync_base_height
1320+ ) ;
13111321 return Ok ( None ) ;
13121322 }
13131323 } else {
@@ -1904,8 +1914,8 @@ mod tests {
19041914 #[ tokio:: test]
19051915 async fn test_checkpoint_storage_indexing ( ) -> StorageResult < ( ) > {
19061916 use crate :: types:: ChainState ;
1907- use tempfile:: tempdir;
19081917 use dashcore:: TxMerkleNode ;
1918+ use tempfile:: tempdir;
19091919
19101920 let temp_dir = tempdir ( ) . expect ( "Failed to create temp dir" ) ;
19111921 let mut storage = DiskStorageManager :: new ( temp_dir. path ( ) . to_path_buf ( ) ) . await ?;
@@ -1940,11 +1950,19 @@ mod tests {
19401950 // Test the reverse index (hash -> blockchain height)
19411951 let hash_0 = headers[ 0 ] . block_hash ( ) ;
19421952 let height_0 = storage. get_header_height_by_hash ( & hash_0) . await ?;
1943- assert_eq ! ( height_0, Some ( checkpoint_height) , "Hash should map to blockchain height 1,100,000" ) ;
1953+ assert_eq ! (
1954+ height_0,
1955+ Some ( checkpoint_height) ,
1956+ "Hash should map to blockchain height 1,100,000"
1957+ ) ;
19441958
19451959 let hash_99 = headers[ 99 ] . block_hash ( ) ;
19461960 let height_99 = storage. get_header_height_by_hash ( & hash_99) . await ?;
1947- assert_eq ! ( height_99, Some ( checkpoint_height + 99 ) , "Hash should map to blockchain height 1,100,099" ) ;
1961+ assert_eq ! (
1962+ height_99,
1963+ Some ( checkpoint_height + 99 ) ,
1964+ "Hash should map to blockchain height 1,100,099"
1965+ ) ;
19481966
19491967 // Store chain state to persist sync_base_height
19501968 let mut chain_state = ChainState :: new ( ) ;
@@ -1961,12 +1979,18 @@ mod tests {
19611979
19621980 // Verify the index was rebuilt correctly
19631981 let height_after_rebuild = storage2. get_header_height_by_hash ( & hash_0) . await ?;
1964- assert_eq ! ( height_after_rebuild, Some ( checkpoint_height) ,
1965- "After index rebuild, hash should still map to blockchain height 1,100,000" ) ;
1982+ assert_eq ! (
1983+ height_after_rebuild,
1984+ Some ( checkpoint_height) ,
1985+ "After index rebuild, hash should still map to blockchain height 1,100,000"
1986+ ) ;
19661987
19671988 // Verify headers can still be retrieved by storage index
19681989 let header_after_reload = storage2. get_header ( 0 ) . await ?;
1969- assert ! ( header_after_reload. is_some( ) , "Header at storage index 0 should exist after reload" ) ;
1990+ assert ! (
1991+ header_after_reload. is_some( ) ,
1992+ "Header at storage index 0 should exist after reload"
1993+ ) ;
19701994 assert_eq ! ( header_after_reload. unwrap( ) , headers[ 0 ] ) ;
19711995
19721996 Ok ( ( ) )
0 commit comments