fn write_post_migration_info(
    state_hash: Digest,
    new_protocol_version: ProtocolVersion,
    secret_key: &SecretKey,
    path: PathBuf,
) -> Result<(), Error> {
    // Serialize the info.
    let info = PostMigrationInfo {
        state_hash,
        protocol_version: new_protocol_version,
    };
    let serialized_info = bincode::serialize(&info).map_err(Error::SerializeStateHashInfo)?;

    // Sign the info.
    let public_key = PublicKey::from(secret_key);
    let signature = crypto::sign(&serialized_info, secret_key, &public_key);
    let signed_info = SignedPostMigrationInfo {
        serialized_info,
        signature,
    };

    // Write the signed info to disk.
    let serialized_signed_info =
        bincode::serialize(&signed_info).map_err(Error::SerializeStateHashInfo)?;
    fs::write(&path, serialized_signed_info).map_err(|error| Error::WriteStateHashInfo {
        path: path.display().to_string(),
        error,
    })?;

    info!(path=%path.display(), "wrote post-migration state hash");
    Ok(())
}
/// Writes the root hash of the global state and the new protocol version after data migration has
/// completed.
///
/// This must be called after a data migration in order to allow the node to read in the new root
/// state on restart.
Writes the root hash of the global state and the new protocol version after data migration has
completed.

This must be called after a data migration in order to allow the node to read in the new root
state on restart.
Writes the root hash of the global state and the new protocol version after data migration has completed . This must be called after a data migration in order to allow the node to read in the new root state on restart .
fn write_post_migration_info(
    state_hash: Digest,
    new_protocol_version: ProtocolVersion,
    secret_key: &SecretKey,
    path: PathBuf,
) -> Result<(), Error> {
    // Serialize the info.
    let info = PostMigrationInfo {
        state_hash,
        protocol_version: new_protocol_version,
    };
    let serialized_info = bincode::serialize(&info).map_err(Error::SerializeStateHashInfo)?;
    // Sign the info.
    let public_key = PublicKey::from(secret_key);
    let signature = crypto::sign(&serialized_info, secret_key, &public_key);
    let signed_info = SignedPostMigrationInfo {
        serialized_info,
        signature,
    };
    // Write the signed info to disk.
    let serialized_signed_info =
        bincode::serialize(&signed_info).map_err(Error::SerializeStateHashInfo)?;
    fs::write(&path, serialized_signed_info).map_err(|error| Error::WriteStateHashInfo {
        path: path.display().to_string(),
        error,
    })?;
    info!(path=%path.display(), "wrote post-migration state hash");
    Ok(())
}
fn write_post_migration_info ( state_hash : Digest , new_protocol_version : ProtocolVersion , secret_key : & SecretKey , path : PathBuf , ) -> Result < ( ) , Error > { // Serialize the info. let info = PostMigrationInfo { state_hash , protocol_version : new_protocol_version , } ; let serialized_info = bincode :: serialize ( & info ) . map_err ( Error :: SerializeStateHashInfo ) ? ; // Sign the info. let public_key = PublicKey :: from ( secret_key ) ; let signature = crypto :: sign ( & serialized_info , secret_key , & public_key ) ; let signed_info = SignedPostMigrationInfo { serialized_info , signature , } ; // Write the signed info to disk. let serialized_signed_info = bincode :: serialize ( & signed_info ) . map_err ( Error :: SerializeStateHashInfo ) ? ; fs :: write ( & path , serialized_signed_info ) . map_err ( | error | Error :: WriteStateHashInfo { path : path . display ( ) . to_string ( ) , error , } ) ? ; info ! ( path path display ( ) " " ) ; Ok ( ( ) ) }
Writes the root hash of the global state and the new protocol version after data migration has
completed.
Writes the root hash of the global state and the new protocol version after data migration has completed .
state_hash
Digest
new_protocol_version
ProtocolVersion
secret_key
&SecretKey
path
PathBuf
state_hash
Digest
new_protocol_version
ProtocolVersion
secret_key
&SecretKey
path
PathBuf