/// Imports a checkpoint of replicated state into the replica state directory.
///
/// Function is not crash-safe. Caller is responsible to follow guidelines
/// regarding crash-safe I/O.
Imports a checkpoint of replicated state into the replica state directory.
Function is not crash-safe. Caller is responsible to follow guidelines
regarding crash-safe I/O.
Imports a checkpoint of replicated state into the replica state directory . Function is not crash - safe . Caller is responsible to follow guidelines regarding crash - safe I / O .
pub fn do_import(state_path: PathBuf, config_path: PathBuf, height: u64) -> Result<(), String> {
    let state_layout = utils::locate_state_root(config_path)?;
    let height = Height::new(height);
    if let Ok(cp_layout) = state_layout.checkpoint(height) {
        return Err(format!(
            "Checkpoint {} already exists at {}",
            height,
            cp_layout.raw_path().display()
        ));
    }
    let scratchpad_dir = state_layout
        .state_sync_scratchpad(height)
        .map_err(|e| format!("Failed to get a scratchpad directory: {}", e))?;
    copy_recursively(&state_path, &scratchpad_dir)?;
    let cp_layout = CheckpointLayout::<RwPolicy>::new(scratchpad_dir, height)
        .map_err(|e| format!("Failed to create scratchpad checkpoint layout: {}", e))?;
    state_layout
        .scratchpad_to_checkpoint(cp_layout, height)
        .map_err(|e| e.to_string())?;
    println!(
        "Successfully created checkpoint {} in state root {}",
        height,
        state_layout.raw_path().display()
    );
    Ok(())
}
pub fn do_import ( state_path : PathBuf , config_path : PathBuf , height : u64 ) -> Result < ( ) , String > { let state_layout = utils :: locate_state_root ( config_path ) ? ; let height = Height :: new ( height ) ; if let Ok ( cp_layout ) = state_layout . checkpoint ( height ) { return Err ( format ! ( " " height cp_layout raw_path ( ) display ( ) ) ) ; } let scratchpad_dir = state_layout . state_sync_scratchpad ( height ) . map_err ( | e | format ! ( " " e ) ) ? ; copy_recursively ( & state_path , & scratchpad_dir ) ? ; let cp_layout = CheckpointLayout :: < RwPolicy > :: new ( scratchpad_dir , height ) . map_err ( | e | format ! ( " " e ) ) ? ; state_layout . scratchpad_to_checkpoint ( cp_layout , height ) . map_err ( | e | e . to_string ( ) ) ? ; println ! ( " " height state_layout raw_path ( ) display ( ) ) ; Ok ( ( ) ) }
Imports a checkpoint of replicated state into the replica state directory.
Imports a checkpoint of replicated state into the replica state directory .
state_path
PathBuf
config_path
PathBuf
height
u64