pub async fn new_for_backup(
        mut cfg: Config,
        replica_version: ReplicaVersion,
        backup_spool_path: &Path,
        registry_local_store_path: &Path,
        subnet_id: SubnetId,
        start_height: u64,
    ) -> Self {
        let logger = LoggerImpl::new(&cfg.logger, "ic-replay".to_string());
        let log = new_replica_logger(logger.root.clone(), &cfg.logger);
        let data_provided_config = cfg
            .registry_client
            .data_provider
            .as_ref()
            .expect("No registry provider found");

        // In the special case where we start from the Genesis height, we want to clean
        // up the execution state before.
        if start_height == 0 {
            let state_path = &cfg.state_manager.state_root();
            let registry_path = match &cfg.registry_client.data_provider {
                Some(DataProviderConfig::LocalStore(path)) => path,
                _ => panic!("The registry local store path is not configured."),
            };
            delete_folders_if_consent_given(state_path, registry_path);
            let data_provider = create_data_provider(
                &DataProviderConfig::LocalStore(registry_local_store_path.into()),
                None,
            );
            // Because we use the LocalStoreImpl, we know that we get the
            // registry in one chunk when calling get_update_since().
            let records = data_provider
                .get_updates_since(RegistryVersion::from(0))
                .expect("Couldn't get the initial registry contents");
            if let DataProviderConfig::LocalStore(path) = data_provided_config {
                write_records_to_local_store(path, RegistryVersion::from(0), records);
            } else {
                panic!("The replica config must point to a registry local store");
            }
        }

        let data_provider = create_data_provider(data_provided_config, None);
        let registry = Arc::new(RegistryClientImpl::new(data_provider, None));
        registry
            .poll_once()
            .expect("Couldn't poll the registry data provider");
        // Since we read all artifacts from the disc, we don't care about the initial
        // state of the consensus pool.
        let tmp_dir = tempfile::Builder::new()
            .prefix("replay_artifact_pool_")
            .tempdir()
            .expect("Couldn't create a temporary directory");
        cfg.artifact_pool.consensus_pool_path = tmp_dir.path().into();
        // If the backup was configured, make sure we switch it off during the replay.
        cfg.artifact_pool.backup = None;
        println!(
            "Using {:?} for the temporary consensus pool...",
            cfg.artifact_pool.consensus_pool_path
        );
        let artifact_pool_config = ArtifactPoolConfig::from(cfg.artifact_pool.clone());
        let backup_dir = backup_spool_path
            .join(subnet_id.to_string())
            .join(replica_version.to_string());
        // Extract the genesis CUP and instantiate a new pool.
        let initial_cup = backup::read_cup_at_height(
            registry.clone(),
            subnet_id,
            &backup_dir,
            Height::from(start_height),
        );
        // This would create a new pool with just the genesis CUP.
        let pool = ConsensusPoolImpl::new_from_cup_without_bytes(
            subnet_id,
            initial_cup,
            artifact_pool_config,
            MetricsRegistry::global(),
            log.clone(),
        );

        let mut player = Player::new_with_params(
            cfg,
            Arc::new(backup::MockVerifier {}),
            registry,
            subnet_id,
            Some(pool),
            log,
            Some(backup_dir),
            replica_version,
        )
        .await;
        player.tmp_dir = Some(tmp_dir);
        player
    }
/// Create and return a `Player` from a replica configuration object for
/// restoring states from backups.
Create and return a `Player` from a replica configuration object for
restoring states from backups.
Create and return a ` Player ` from a replica configuration object for restoring states from backups .
pub async fn new_for_backup(
        mut cfg: Config,
        replica_version: ReplicaVersion,
        backup_spool_path: &Path,
        registry_local_store_path: &Path,
        subnet_id: SubnetId,
        start_height: u64,
    ) -> Self {
        let logger = LoggerImpl::new(&cfg.logger, "ic-replay".to_string());
        let log = new_replica_logger(logger.root.clone(), &cfg.logger);
        let data_provided_config = cfg
            .registry_client
            .data_provider
            .as_ref()
            .expect("No registry provider found");
        // In the special case where we start from the Genesis height, we want to clean
        // up the execution state before.
        if start_height == 0 {
            let state_path = &cfg.state_manager.state_root();
            let registry_path = match &cfg.registry_client.data_provider {
                Some(DataProviderConfig::LocalStore(path)) => path,
                _ => panic!("The registry local store path is not configured."),
            };
            delete_folders_if_consent_given(state_path, registry_path);
            let data_provider = create_data_provider(
                &DataProviderConfig::LocalStore(registry_local_store_path.into()),
                None,
            );
            // Because we use the LocalStoreImpl, we know that we get the
            // registry in one chunk when calling get_update_since().
            let records = data_provider
                .get_updates_since(RegistryVersion::from(0))
                .expect("Couldn't get the initial registry contents");
            if let DataProviderConfig::LocalStore(path) = data_provided_config {
                write_records_to_local_store(path, RegistryVersion::from(0), records);
            } else {
                panic!("The replica config must point to a registry local store");
            }
        }
        let data_provider = create_data_provider(data_provided_config, None);
        let registry = Arc::new(RegistryClientImpl::new(data_provider, None));
        registry
            .poll_once()
            .expect("Couldn't poll the registry data provider");
        // Since we read all artifacts from the disc, we don't care about the initial
        // state of the consensus pool.
        let tmp_dir = tempfile::Builder::new()
            .prefix("replay_artifact_pool_")
            .tempdir()
            .expect("Couldn't create a temporary directory");
        cfg.artifact_pool.consensus_pool_path = tmp_dir.path().into();
        // If the backup was configured, make sure we switch it off during the replay.
        cfg.artifact_pool.backup = None;
        println!(
            "Using {:?} for the temporary consensus pool...",
            cfg.artifact_pool.consensus_pool_path
        );
        let artifact_pool_config = ArtifactPoolConfig::from(cfg.artifact_pool.clone());
        let backup_dir = backup_spool_path
            .join(subnet_id.to_string())
            .join(replica_version.to_string());
        // Extract the genesis CUP and instantiate a new pool.
        let initial_cup = backup::read_cup_at_height(
            registry.clone(),
            subnet_id,
            &backup_dir,
            Height::from(start_height),
        );
        // This would create a new pool with just the genesis CUP.
        let pool = ConsensusPoolImpl::new_from_cup_without_bytes(
            subnet_id,
            initial_cup,
            artifact_pool_config,
            MetricsRegistry::global(),
            log.clone(),
        );
        let mut player = Player::new_with_params(
            cfg,
            Arc::new(backup::MockVerifier {}),
            registry,
            subnet_id,
            Some(pool),
            log,
            Some(backup_dir),
            replica_version,
        )
        .await;
        player.tmp_dir = Some(tmp_dir);
        player
    }
pub async fn new_for_backup ( mut cfg : Config , replica_version : ReplicaVersion , backup_spool_path : & Path , registry_local_store_path : & Path , subnet_id : SubnetId , start_height : u64 , ) -> Self { let logger = LoggerImpl :: new ( & cfg . logger , " " . to_string ( ) ) ; let log = new_replica_logger ( logger . root . clone ( ) , & cfg . logger ) ; let data_provided_config = cfg . registry_client . data_provider . as_ref ( ) . expect ( " " ) ; // In the special case where we start from the Genesis height, we want to clean // up the execution state before. if start_height == 0 { let state_path = & cfg . state_manager . state_root ( ) ; let registry_path = match & cfg . registry_client . data_provider { Some ( DataProviderConfig :: LocalStore ( path ) ) => path , _ => panic ! ( " " ) , } ; delete_folders_if_consent_given ( state_path , registry_path ) ; let data_provider = create_data_provider ( & DataProviderConfig :: LocalStore ( registry_local_store_path . into ( ) ) , None , ) ; // Because we use the LocalStoreImpl, we know that we get the // registry in one chunk when calling get_update_since(). let records = data_provider . get_updates_since ( RegistryVersion :: from ( 0 ) ) . expect ( " " ) ; if let DataProviderConfig :: LocalStore ( path ) = data_provided_config { write_records_to_local_store ( path , RegistryVersion :: from ( 0 ) , records ) ; } else { panic ! ( " " ) ; } } let data_provider = create_data_provider ( data_provided_config , None ) ; let registry = Arc :: new ( RegistryClientImpl :: new ( data_provider , None ) ) ; registry . poll_once ( ) . expect ( " " ) ; // Since we read all artifacts from the disc, we don't care about the initial // state of the consensus pool. let tmp_dir = tempfile :: Builder :: new ( ) . prefix ( " " ) . tempdir ( ) . expect ( " " ) ; cfg . artifact_pool . consensus_pool_path = tmp_dir . path ( ) . into ( ) ; // If the backup was configured, make sure we switch it off during the replay. cfg . artifact_pool . backup = None ; println ! ( " " cfg artifact_pool consensus_pool_path ) ; let artifact_pool_config = ArtifactPoolConfig :: from ( cfg . artifact_pool . clone ( ) ) ; let backup_dir = backup_spool_path . join ( subnet_id . to_string ( ) ) . join ( replica_version . to_string ( ) ) ; // Extract the genesis CUP and instantiate a new pool. let initial_cup = backup :: read_cup_at_height ( registry . clone ( ) , subnet_id , & backup_dir , Height :: from ( start_height ) , ) ; // This would create a new pool with just the genesis CUP. let pool = ConsensusPoolImpl :: new_from_cup_without_bytes ( subnet_id , initial_cup , artifact_pool_config , MetricsRegistry :: global ( ) , log . clone ( ) , ) ; let mut player = Player :: new_with_params ( cfg , Arc :: new ( backup :: MockVerifier { } ) , registry , subnet_id , Some ( pool ) , log , Some ( backup_dir ) , replica_version , ) . await ; player . tmp_dir = Some ( tmp_dir ) ; player }
Create and return a `Player` from a replica configuration object for
restoring states from backups.
Create and return a ` Player ` from a replica configuration object for restoring states from backups .
cfg
Config
replica_version
ReplicaVersion
backup_spool_path
&Path
registry_local_store_path
&Path
subnet_id
SubnetId
start_height
u64
cfg
Config
replica_version
ReplicaVersion
backup_spool_path
&Path
registry_local_store_path
&Path
subnet_id
SubnetId
start_height
u64