@@ -28,7 +28,7 @@ use crate::error::{
2828 ApplyOperationsSnafu , BlockArchiveNotConfiguredSnafu , BlockReadSnafu , IndexLookupSnafu ,
2929 RecoveryError , StateRootComputationSnafu ,
3030} ;
31- use crate :: log_storage:: { AppliedStateAccessor , VaultHealthStatus , MAX_RECOVERY_ATTEMPTS } ;
31+ use crate :: log_storage:: { AppliedStateAccessor , MAX_RECOVERY_ATTEMPTS , VaultHealthStatus } ;
3232use crate :: types:: { LedgerNodeId , LedgerRequest , LedgerResponse , LedgerTypeConfig } ;
3333
3434/// Default interval between recovery scans.
@@ -144,7 +144,10 @@ impl AutoRecoveryJob {
144144 /// Calculate retry delay with exponential backoff.
145145 fn retry_delay ( & self , attempt : u8 ) -> Duration {
146146 let multiplier = 2u64 . saturating_pow ( attempt. saturating_sub ( 1 ) as u32 ) ;
147- let delay = self . config . base_retry_delay . saturating_mul ( multiplier as u32 ) ;
147+ let delay = self
148+ . config
149+ . base_retry_delay
150+ . saturating_mul ( multiplier as u32 ) ;
148151 std:: cmp:: min ( delay, self . config . max_retry_delay )
149152 }
150153
@@ -171,7 +174,10 @@ impl AutoRecoveryJob {
171174 VaultHealthStatus :: Diverged { .. } => {
172175 needs_recovery. push ( ( namespace_id, vault_id, health) ) ;
173176 }
174- VaultHealthStatus :: Recovering { started_at, attempt } => {
177+ VaultHealthStatus :: Recovering {
178+ started_at,
179+ attempt,
180+ } => {
175181 if * attempt < MAX_RECOVERY_ATTEMPTS
176182 && self . is_ready_for_retry ( * started_at, * attempt)
177183 {
@@ -213,7 +219,16 @@ impl AutoRecoveryJob {
213219 // First, transition to Recovering state
214220 let now = chrono:: Utc :: now ( ) . timestamp ( ) ;
215221 if let Err ( e) = self
216- . propose_health_update ( namespace_id, vault_id, false , None , None , None , Some ( attempt) , Some ( now) )
222+ . propose_health_update (
223+ namespace_id,
224+ vault_id,
225+ false ,
226+ None ,
227+ None ,
228+ None ,
229+ Some ( attempt) ,
230+ Some ( now) ,
231+ )
217232 . await
218233 {
219234 warn ! (
@@ -228,9 +243,7 @@ impl AutoRecoveryJob {
228243
229244 info ! (
230245 namespace_id,
231- vault_id,
232- attempt,
233- "Starting vault recovery attempt"
246+ vault_id, attempt, "Starting vault recovery attempt"
234247 ) ;
235248
236249 // Get the expected state root from the divergence info
@@ -258,7 +271,16 @@ impl AutoRecoveryJob {
258271 if computed_root == expected_root || expected_root == ledger_types:: ZERO_HASH {
259272 // Recovery successful
260273 if let Err ( e) = self
261- . propose_health_update ( namespace_id, vault_id, true , None , None , None , None , None )
274+ . propose_health_update (
275+ namespace_id,
276+ vault_id,
277+ true ,
278+ None ,
279+ None ,
280+ None ,
281+ None ,
282+ None ,
283+ )
262284 . await
263285 {
264286 warn ! (
@@ -320,10 +342,7 @@ impl AutoRecoveryJob {
320342
321343 debug ! (
322344 namespace_id,
323- vault_id,
324- start_height,
325- tip_height,
326- "Replaying vault state for recovery"
345+ vault_id, start_height, tip_height, "Replaying vault state for recovery"
327346 ) ;
328347
329348 // Replay blocks from start_height to tip
@@ -385,10 +404,7 @@ impl AutoRecoveryJob {
385404 . iter ( )
386405 . find ( |v| v. vault_id == vault_id)
387406 {
388- return Ok ( (
389- vault_state. vault_height + 1 ,
390- vault_state. state_root ,
391- ) ) ;
407+ return Ok ( ( vault_state. vault_height + 1 , vault_state. state_root ) ) ;
392408 }
393409 }
394410 }
@@ -423,14 +439,14 @@ impl AutoRecoveryJob {
423439 recovery_started_at,
424440 } ;
425441
426- let result = self
427- . raft
428- . client_write ( request)
429- . await
430- . map_err ( |e| RecoveryError :: RaftConsensus {
431- message : format ! ( "{:?}" , e) ,
432- backtrace : snafu:: Backtrace :: generate ( ) ,
433- } ) ?;
442+ let result =
443+ self . raft
444+ . client_write ( request)
445+ . await
446+ . map_err ( |e| RecoveryError :: RaftConsensus {
447+ message : format ! ( "{:?}" , e) ,
448+ backtrace : snafu:: Backtrace :: generate ( ) ,
449+ } ) ?;
434450
435451 match result. data {
436452 LedgerResponse :: VaultHealthUpdated { success : true } => Ok ( ( ) ) ,
0 commit comments