Refactor genesis download/load/check functions (#17276)

* Refactor genesis ingest functions

* Consolidate genesis.bin/genesis.tar.bz2 references
This commit is contained in:
sakridge
2021-05-24 16:45:36 +02:00
committed by GitHub
parent 9d112cf41f
commit a8dca3976b
11 changed files with 158 additions and 100 deletions

View File

@ -1,3 +1,4 @@
use solana_sdk::genesis_config::{DEFAULT_GENESIS_ARCHIVE, DEFAULT_GENESIS_FILE};
use {
bzip2::bufread::BzDecoder,
log::*,
@ -280,7 +281,7 @@ pub fn open_genesis_config(
max_genesis_archive_unpacked_size: u64,
) -> GenesisConfig {
GenesisConfig::load(&ledger_path).unwrap_or_else(|load_err| {
let genesis_package = ledger_path.join("genesis.tar.bz2");
let genesis_package = ledger_path.join(DEFAULT_GENESIS_ARCHIVE);
unpack_genesis_archive(
&genesis_package,
ledger_path,
@ -348,8 +349,8 @@ fn is_valid_genesis_archive_entry(parts: &[&str], kind: tar::EntryType) -> bool
trace!("validating: {:?} {:?}", parts, kind);
#[allow(clippy::match_like_matches_macro)]
match (parts, kind) {
(["genesis.bin"], GNUSparse) => true,
(["genesis.bin"], Regular) => true,
([DEFAULT_GENESIS_FILE], GNUSparse) => true,
([DEFAULT_GENESIS_FILE], Regular) => true,
(["rocksdb"], Directory) => true,
(["rocksdb", _], GNUSparse) => true,
(["rocksdb", _], Regular) => true,