// Initialize the replica by downloading snapshot from the peer, initialize
// the BankForks, OptimisticallyConfirmedBank, LeaderScheduleCache and
// BlockCommitmentCache and return the info wrapped as ReplicaBankInfo.
Initialize the replica by downloading snapshot from the peer, initialize
the BankForks, OptimisticallyConfirmedBank, LeaderScheduleCache and
BlockCommitmentCache and return the info wrapped as ReplicaBankInfo.
Initialize the replica by downloading snapshot from the peer initialize the BankForks OptimisticallyConfirmedBank LeaderScheduleCache and BlockCommitmentCache and return the info wrapped as ReplicaBankInfo .
fn initialize_from_snapshot(
    replica_config: &ReplicaNodeConfig,
    snapshot_config: &SnapshotConfig,
    genesis_config: &GenesisConfig,
) -> ReplicaBankInfo {
    info!(
        "Downloading snapshot from the peer into {:?}",
        replica_config.snapshot_output_dir
    );
    download_snapshot(
        &replica_config.rpc_source_addr,
        &replica_config.snapshot_output_dir,
        replica_config.snapshot_info,
        false,
        snapshot_config.maximum_snapshots_to_retain,
        &mut None,
    )
    .unwrap();
    fs::create_dir_all(&snapshot_config.snapshot_path).expect("Couldn't create snapshot directory");
    let archive_info =
        snapshot_utils::get_highest_full_snapshot_archive_info(&replica_config.snapshot_output_dir)
            .unwrap();
    let process_options = blockstore_processor::ProcessOptions {
        account_indexes: replica_config.account_indexes.clone(),
        accounts_db_caching_enabled: replica_config.accounts_db_caching_enabled,
        ..blockstore_processor::ProcessOptions::default()
    };
    info!(
        "Build bank from snapshot archive: {:?}",
        &snapshot_config.snapshot_path
    );
    let (bank0, _) = snapshot_utils::bank_from_snapshot_archives(
        &replica_config.account_paths,
        &[],
        &snapshot_config.snapshot_path,
        &archive_info,
        None,
        genesis_config,
        process_options.debug_keys.clone(),
        None,
        process_options.account_indexes.clone(),
        process_options.accounts_db_caching_enabled,
        process_options.limit_load_slot_count_from_snapshot,
        process_options.shrink_ratio,
        process_options.accounts_db_test_hash_calculation,
        false,
        process_options.verify_index,
        process_options.accounts_index_config,
    )
    .unwrap();
    let bank0_slot = bank0.slot();
    let leader_schedule_cache = Arc::new(LeaderScheduleCache::new_from_bank(&bank0));
    let bank_forks = Arc::new(RwLock::new(BankForks::new(bank0)));
    let optimistically_confirmed_bank =
        OptimisticallyConfirmedBank::locked_from_bank_forks_root(&bank_forks);
    let mut block_commitment_cache = BlockCommitmentCache::default();
    block_commitment_cache.initialize_slots(bank0_slot);
    let block_commitment_cache = Arc::new(RwLock::new(block_commitment_cache));
    ReplicaBankInfo {
        bank_forks,
        optimistically_confirmed_bank,
        leader_schedule_cache,
        block_commitment_cache,
    }
}
fn initialize_from_snapshot ( replica_config : & ReplicaNodeConfig , snapshot_config : & SnapshotConfig , genesis_config : & GenesisConfig , ) -> ReplicaBankInfo { info ! ( " " replica_config snapshot_output_dir ) ; download_snapshot ( & replica_config . rpc_source_addr , & replica_config . snapshot_output_dir , replica_config . snapshot_info , false , snapshot_config . maximum_snapshots_to_retain , & mut None , ) . unwrap ( ) ; fs :: create_dir_all ( & snapshot_config . snapshot_path ) . expect ( " " ) ; let archive_info = snapshot_utils :: get_highest_full_snapshot_archive_info ( & replica_config . snapshot_output_dir ) . unwrap ( ) ; let process_options = blockstore_processor :: ProcessOptions { account_indexes : replica_config . account_indexes . clone ( ) , accounts_db_caching_enabled : replica_config . accounts_db_caching_enabled , .. blockstore_processor :: ProcessOptions :: default ( ) } ; info ! ( " " snapshot_config snapshot_path ) ; let ( bank0 , _ ) = snapshot_utils :: bank_from_snapshot_archives ( & replica_config . account_paths , & [ ] , & snapshot_config . snapshot_path , & archive_info , None , genesis_config , process_options . debug_keys . clone ( ) , None , process_options . account_indexes . clone ( ) , process_options . accounts_db_caching_enabled , process_options . limit_load_slot_count_from_snapshot , process_options . shrink_ratio , process_options . accounts_db_test_hash_calculation , false , process_options . verify_index , process_options . accounts_index_config , ) . unwrap ( ) ; let bank0_slot = bank0 . slot ( ) ; let leader_schedule_cache = Arc :: new ( LeaderScheduleCache :: new_from_bank ( & bank0 ) ) ; let bank_forks = Arc :: new ( RwLock :: new ( BankForks :: new ( bank0 ) ) ) ; let optimistically_confirmed_bank = OptimisticallyConfirmedBank :: locked_from_bank_forks_root ( & bank_forks ) ; let mut block_commitment_cache = BlockCommitmentCache :: default ( ) ; block_commitment_cache . initialize_slots ( bank0_slot ) ; let block_commitment_cache = Arc :: new ( RwLock :: new ( block_commitment_cache ) ) ; ReplicaBankInfo { bank_forks , optimistically_confirmed_bank , leader_schedule_cache , block_commitment_cache , } }
Initialize the replica by downloading snapshot from the peer, initialize
the BankForks, OptimisticallyConfirmedBank, LeaderScheduleCache and
BlockCommitmentCache and return the info wrapped as ReplicaBankInfo.
Initialize the replica by downloading snapshot from the peer initialize the BankForks OptimisticallyConfirmedBank LeaderScheduleCache and BlockCommitmentCache and return the info wrapped as ReplicaBankInfo .
replica_config
&ReplicaNodeConfig
snapshot_config
&SnapshotConfig
genesis_config
&GenesisConfig