Revert "Ledger-tool: only require ledger dir when necessary (backport #21575) (#21578)"

This reverts commit 5a7b487e3d.
This commit is contained in:
Trent Nelson
2021-12-13 08:48:39 -07:00
committed by Tao Zhu
parent d7377d4794
commit eae3166bdc
3 changed files with 1488 additions and 1542 deletions

View File

@@ -1,26 +1,23 @@
/// The `bigtable` subcommand /// The `bigtable` subcommand
use { use clap::{
crate::ledger_path::canonicalize_ledger_path, value_t, value_t_or_exit, values_t_or_exit, App, AppSettings, Arg, ArgMatches, SubCommand,
clap::{ };
value_t, value_t_or_exit, values_t_or_exit, App, AppSettings, Arg, ArgMatches, SubCommand, use solana_clap_utils::{
}, input_parsers::pubkey_of,
solana_clap_utils::{ input_validators::{is_slot, is_valid_pubkey},
input_parsers::pubkey_of, };
input_validators::{is_slot, is_valid_pubkey}, use solana_cli_output::{
}, display::println_transaction, CliBlock, CliTransaction, CliTransactionConfirmation,
solana_cli_output::{ OutputFormat,
display::println_transaction, CliBlock, CliTransaction, CliTransactionConfirmation, };
OutputFormat, use solana_ledger::{blockstore::Blockstore, blockstore_db::AccessType};
}, use solana_sdk::{clock::Slot, pubkey::Pubkey, signature::Signature};
solana_ledger::{blockstore::Blockstore, blockstore_db::AccessType}, use solana_transaction_status::{ConfirmedBlock, EncodedTransaction, UiTransactionEncoding};
solana_sdk::{clock::Slot, pubkey::Pubkey, signature::Signature}, use std::{
solana_transaction_status::{ConfirmedBlock, EncodedTransaction, UiTransactionEncoding}, path::Path,
std::{ process::exit,
path::Path, result::Result,
process::exit, sync::{atomic::AtomicBool, Arc},
result::Result,
sync::{atomic::AtomicBool, Arc},
},
}; };
async fn upload( async fn upload(
@@ -429,11 +426,8 @@ pub fn bigtable_process_command(ledger_path: &Path, matches: &ArgMatches<'_>) {
let ending_slot = value_t!(arg_matches, "ending_slot", Slot).ok(); let ending_slot = value_t!(arg_matches, "ending_slot", Slot).ok();
let allow_missing_metadata = arg_matches.is_present("allow_missing_metadata"); let allow_missing_metadata = arg_matches.is_present("allow_missing_metadata");
let force_reupload = arg_matches.is_present("force_reupload"); let force_reupload = arg_matches.is_present("force_reupload");
let blockstore = crate::open_blockstore( let blockstore =
&canonicalize_ledger_path(ledger_path), crate::open_blockstore(ledger_path, AccessType::TryPrimaryThenSecondary, None);
AccessType::TryPrimaryThenSecondary,
None,
);
runtime.block_on(upload( runtime.block_on(upload(
blockstore, blockstore,

View File

@@ -1,30 +0,0 @@
use {
clap::{value_t, ArgMatches},
std::{
fs,
path::{Path, PathBuf},
process::exit,
},
};
pub fn parse_ledger_path(matches: &ArgMatches<'_>, name: &str) -> PathBuf {
PathBuf::from(value_t!(matches, name, String).unwrap_or_else(|_err| {
eprintln!(
"Error: Missing --ledger <DIR> argument.\n\n{}",
matches.usage()
);
exit(1);
}))
}
// Canonicalize ledger path to avoid issues with symlink creation
pub fn canonicalize_ledger_path(ledger_path: &Path) -> PathBuf {
fs::canonicalize(&ledger_path).unwrap_or_else(|err| {
eprintln!(
"Unable to access ledger path '{}': {}",
ledger_path.display(),
err
);
exit(1);
})
}

File diff suppressed because it is too large Load Diff