fn verify_level_cache_store<Tree: MerkleTreeTrait>(config: &StoreConfig) -> Result<()> {
    let store_path = StoreConfig::data_path(&config.path, &config.id);
    if !Path::new(&store_path).exists() {
        let required_configs = get_base_tree_count::<Tree>();

        // Configs may have split due to sector size, so we need to
        // check deterministic paths from here.
        let orig_path = store_path
            .clone()
            .into_os_string()
            .into_string()
            .expect("failed to convert store_path to string");
        let mut configs: Vec<StoreConfig> = Vec::with_capacity(required_configs);
        for i in 0..required_configs {
            let cur_path = orig_path
                .clone()
                .replace(".dat", format!("-{}.dat", i).as_str());

            if Path::new(&cur_path).exists() {
                let path_str = cur_path.as_str();
                let tree_names = vec!["tree-d", "tree-c", "tree-r-last"];
                for name in tree_names {
                    if path_str.find(name).is_some() {
                        configs.push(StoreConfig::from_config(
                            config,
                            format!("{}-{}", name, i),
                            None,
                        ));
                        break;
                    }
                }
            }
        }

        ensure!(
            configs.len() == required_configs,
            "Missing store file (or associated split paths): {}",
            store_path.display()
        );

        let store_len = config.size.expect("disk store size not configured");
        for config in &configs {
            ensure!(
                LevelCacheStore::<DefaultPieceDomain, std::fs::File>::is_consistent(
                    store_len,
                    Tree::Arity::to_usize(),
                    &config,
                )?,
                "Store is inconsistent: {:?}",
                StoreConfig::data_path(&config.path, &config.id)
            );
        }
    } else {
        ensure!(
            LevelCacheStore::<DefaultPieceDomain, std::fs::File>::is_consistent(
                config.size.expect("disk store size not configured"),
                Tree::Arity::to_usize(),
                &config,
            )?,
            "Store is inconsistent: {:?}",
            store_path
        );
    }

    Ok(())
}
// Verifies if a LevelCacheStore specified by a config is consistent.
Verifies if a LevelCacheStore specified by a config is consistent.
Verifies if a LevelCacheStore specified by a config is consistent .
fn verify_level_cache_store<Tree: MerkleTreeTrait>(config: &StoreConfig) -> Result<()> {
    let store_path = StoreConfig::data_path(&config.path, &config.id);
    if !Path::new(&store_path).exists() {
        let required_configs = get_base_tree_count::<Tree>();
        // Configs may have split due to sector size, so we need to
        // check deterministic paths from here.
        let orig_path = store_path
            .clone()
            .into_os_string()
            .into_string()
            .expect("failed to convert store_path to string");
        let mut configs: Vec<StoreConfig> = Vec::with_capacity(required_configs);
        for i in 0..required_configs {
            let cur_path = orig_path
                .clone()
                .replace(".dat", format!("-{}.dat", i).as_str());
            if Path::new(&cur_path).exists() {
                let path_str = cur_path.as_str();
                let tree_names = vec!["tree-d", "tree-c", "tree-r-last"];
                for name in tree_names {
                    if path_str.find(name).is_some() {
                        configs.push(StoreConfig::from_config(
                            config,
                            format!("{}-{}", name, i),
                            None,
                        ));
                        break;
                    }
                }
            }
        }
        ensure!(
            configs.len() == required_configs,
            "Missing store file (or associated split paths): {}",
            store_path.display()
        );
        let store_len = config.size.expect("disk store size not configured");
        for config in &configs {
            ensure!(
                LevelCacheStore::<DefaultPieceDomain, std::fs::File>::is_consistent(
                    store_len,
                    Tree::Arity::to_usize(),
                    &config,
                )?,
                "Store is inconsistent: {:?}",
                StoreConfig::data_path(&config.path, &config.id)
            );
        }
    } else {
        ensure!(
            LevelCacheStore::<DefaultPieceDomain, std::fs::File>::is_consistent(
                config.size.expect("disk store size not configured"),
                Tree::Arity::to_usize(),
                &config,
            )?,
            "Store is inconsistent: {:?}",
            store_path
        );
    }
    Ok(())
}
fn verify_level_cache_store < Tree : MerkleTreeTrait > ( config : & StoreConfig ) -> Result < ( ) > { let store_path = StoreConfig :: data_path ( & config . path , & config . id ) ; if ! Path :: new ( & store_path ) . exists ( ) { let required_configs = get_base_tree_count :: < Tree > ( ) ; // Configs may have split due to sector size, so we need to // check deterministic paths from here. let orig_path = store_path . clone ( ) . into_os_string ( ) . into_string ( ) . expect ( " " ) ; let mut configs : Vec < StoreConfig > = Vec :: with_capacity ( required_configs ) ; for i in 0 .. required_configs { let cur_path = orig_path . clone ( ) . replace ( " " , format ! ( " " i ) . as_str ( ) ) ; if Path :: new ( & cur_path ) . exists ( ) { let path_str = cur_path . as_str ( ) ; let tree_names = vec ! [ " " " " " " ] ; for name in tree_names { if path_str . find ( name ) . is_some ( ) { configs . push ( StoreConfig :: from_config ( config , format ! ( " " name i ) , None , ) ) ; break ; } } } } ensure ! ( configs len ( ) required_configs " " store_path display ( ) ) ; let store_len = config . size . expect ( " " ) ; for config in & configs { ensure ! ( LevelCacheStore DefaultPieceDomain std fs File is_consistent ( store_len Tree Arity to_usize ( ) config ) " " StoreConfig data_path ( config path config id ) ) ; } } else { ensure ! ( LevelCacheStore DefaultPieceDomain std fs File is_consistent ( config size expect ( " " ) Tree Arity to_usize ( ) config ) " " store_path ) ; } Ok ( ( ) ) }
Verifies if a LevelCacheStore specified by a config is consistent.
Verifies if a LevelCacheStore specified by a config is consistent .
config
&StoreConfig
config
&StoreConfig