@@ -16,6 +16,7 @@ use crate::rpc_pubsub_service::PubSubService;
|
||||
use crate::rpc_service::JsonRpcService;
|
||||
use crate::rpc_subscriptions::RpcSubscriptions;
|
||||
use crate::service::Service;
|
||||
use crate::snapshot_utils;
|
||||
use crate::storage_stage::StorageState;
|
||||
use crate::tpu::Tpu;
|
||||
use crate::tvu::{Sockets, Tvu};
|
||||
@@ -314,21 +315,36 @@ fn get_bank_forks(
|
||||
let (mut bank_forks, bank_forks_info, leader_schedule_cache) = {
|
||||
let mut result = None;
|
||||
if snapshot_config.is_some() {
|
||||
let bank_forks = BankForks::load_from_snapshot(
|
||||
&genesis_block,
|
||||
account_paths.clone(),
|
||||
snapshot_config.as_ref().unwrap(),
|
||||
let snapshot_config = snapshot_config.as_ref().unwrap();
|
||||
|
||||
// Get the path to the tar
|
||||
let tar = snapshot_utils::get_snapshot_tar_path(
|
||||
&snapshot_config.snapshot_package_output_path(),
|
||||
);
|
||||
match bank_forks {
|
||||
Ok(v) => {
|
||||
let bank = &v.working_bank();
|
||||
let fork_info = BankForksInfo {
|
||||
bank_slot: bank.slot(),
|
||||
entry_height: bank.tick_height(),
|
||||
};
|
||||
result = Some((v, vec![fork_info], LeaderScheduleCache::new_from_bank(bank)));
|
||||
}
|
||||
Err(_) => warn!("Failed to load from snapshot, fallback to load from ledger"),
|
||||
|
||||
// Check that the snapshot tar exists, try to load the snapshot if it does
|
||||
if tar.exists() {
|
||||
// Fail hard here if snapshot fails to load, don't silently continue
|
||||
let bank_forks = BankForks::load_from_snapshot(
|
||||
//&genesis_block,
|
||||
account_paths
|
||||
.clone()
|
||||
.expect("Account paths not present when booting from snapshot"),
|
||||
snapshot_config,
|
||||
tar,
|
||||
)
|
||||
.expect("Load from snapshot failed");
|
||||
|
||||
let bank = &bank_forks.working_bank();
|
||||
let fork_info = BankForksInfo {
|
||||
bank_slot: bank.slot(),
|
||||
entry_height: bank.tick_height(),
|
||||
};
|
||||
result = Some((
|
||||
bank_forks,
|
||||
vec![fork_info],
|
||||
LeaderScheduleCache::new_from_bank(bank),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user