pub(crate) fn read_cup_at_height(
    registry: Arc<dyn RegistryClient>,
    subnet_id: SubnetId,
    backup_dir: &Path,
    height: Height,
) -> CatchUpPackage {
    let group_key = (height.get() / BACKUP_GROUP_SIZE) * BACKUP_GROUP_SIZE;
    let buffer = read_file(
        &backup_dir
            .join(group_key.to_string())
            .join(height.to_string())
            .join("catch_up_package.bin"),
    );

    let protobuf = ic_protobuf::types::v1::CatchUpPackage::decode(buffer.as_slice())
        .expect("Protobuf decoding failed");

    let cup = CatchUpPackage::try_from(&protobuf)
        .unwrap_or_else(|_| panic!("{}", deserialization_error(height)));

    // We cannot verify the genesis CUP with this subnet's public key.
    if height.get() != 0 {
        let crypto =
            ic_crypto::CryptoComponentFatClient::new_for_verification_only(registry.clone());
        crypto
            .verify_combined_threshold_sig_by_public_key(
                &CombinedThresholdSigOf::new(CombinedThresholdSig(protobuf.signature)),
                &CatchUpContentProtobufBytes(protobuf.content),
                subnet_id,
                cup.content.block.get_value().context.registry_version,
            )
            .expect("Verification of the signature on the CUP failed");
    }

    cup
}
/// Deserializes the CUP at the given height and returns it.
Deserializes the CUP at the given height and returns it.
Deserializes the CUP at the given height and returns it .
pub(crate) fn read_cup_at_height(
    registry: Arc<dyn RegistryClient>,
    subnet_id: SubnetId,
    backup_dir: &Path,
    height: Height,
) -> CatchUpPackage {
    let group_key = (height.get() / BACKUP_GROUP_SIZE) * BACKUP_GROUP_SIZE;
    let buffer = read_file(
        &backup_dir
            .join(group_key.to_string())
            .join(height.to_string())
            .join("catch_up_package.bin"),
    );
    let protobuf = ic_protobuf::types::v1::CatchUpPackage::decode(buffer.as_slice())
        .expect("Protobuf decoding failed");
    let cup = CatchUpPackage::try_from(&protobuf)
        .unwrap_or_else(|_| panic!("{}", deserialization_error(height)));
    // We cannot verify the genesis CUP with this subnet's public key.
    if height.get() != 0 {
        let crypto =
            ic_crypto::CryptoComponentFatClient::new_for_verification_only(registry.clone());
        crypto
            .verify_combined_threshold_sig_by_public_key(
                &CombinedThresholdSigOf::new(CombinedThresholdSig(protobuf.signature)),
                &CatchUpContentProtobufBytes(protobuf.content),
                subnet_id,
                cup.content.block.get_value().context.registry_version,
            )
            .expect("Verification of the signature on the CUP failed");
    }
    cup
}
pub ( crate ) fn read_cup_at_height ( registry : Arc < dyn RegistryClient > , subnet_id : SubnetId , backup_dir : & Path , height : Height , ) -> CatchUpPackage { let group_key = ( height . get ( ) / BACKUP_GROUP_SIZE ) * BACKUP_GROUP_SIZE ; let buffer = read_file ( & backup_dir . join ( group_key . to_string ( ) ) . join ( height . to_string ( ) ) . join ( " " ) , ) ; let protobuf = ic_protobuf :: types :: v1 :: CatchUpPackage :: decode ( buffer . as_slice ( ) ) . expect ( " " ) ; let cup = CatchUpPackage :: try_from ( & protobuf ) . unwrap_or_else ( | _ | panic ! ( " " deserialization_error ( height ) ) ) ; // We cannot verify the genesis CUP with this subnet's public key. if height . get ( ) != 0 { let crypto = ic_crypto :: CryptoComponentFatClient :: new_for_verification_only ( registry . clone ( ) ) ; crypto . verify_combined_threshold_sig_by_public_key ( & CombinedThresholdSigOf :: new ( CombinedThresholdSig ( protobuf . signature ) ) , & CatchUpContentProtobufBytes ( protobuf . content ) , subnet_id , cup . content . block . get_value ( ) . context . registry_version , ) . expect ( " " ) ; } cup }
Deserializes the CUP at the given height and returns it.
Deserializes the CUP at the given height and returns it .
registry
Arc<dyn RegistryClient>
subnet_id
SubnetId
backup_dir
&Path
height
Height
registry
Arc<dyn RegistryClient>
subnet_id
SubnetId
backup_dir
&Path
height
Height