Remove AccessType arg from create_new_ledger (#23591)
Creating a new ledger implicitly means that no other process could have previously held access to it. Additionally, creating a new ledger implicitly requires writing, so it follows that Primary access is required and we can drop access type as an argument.
This commit is contained in:
parent
c1bf85b109
commit
e7cf84a593
|
@ -13,10 +13,7 @@ use {
|
||||||
},
|
},
|
||||||
solana_entry::poh::compute_hashes_per_tick,
|
solana_entry::poh::compute_hashes_per_tick,
|
||||||
solana_genesis::{genesis_accounts::add_genesis_accounts, Base64Account},
|
solana_genesis::{genesis_accounts::add_genesis_accounts, Base64Account},
|
||||||
solana_ledger::{
|
solana_ledger::{blockstore::create_new_ledger, blockstore_db::BlockstoreAdvancedOptions},
|
||||||
blockstore::create_new_ledger,
|
|
||||||
blockstore_db::{AccessType, BlockstoreAdvancedOptions},
|
|
||||||
},
|
|
||||||
solana_runtime::hardened_unpack::MAX_GENESIS_ARCHIVE_UNPACKED_SIZE,
|
solana_runtime::hardened_unpack::MAX_GENESIS_ARCHIVE_UNPACKED_SIZE,
|
||||||
solana_sdk::{
|
solana_sdk::{
|
||||||
account::{Account, AccountSharedData, ReadableAccount, WritableAccount},
|
account::{Account, AccountSharedData, ReadableAccount, WritableAccount},
|
||||||
|
@ -632,7 +629,6 @@ fn main() -> Result<(), Box<dyn error::Error>> {
|
||||||
&ledger_path,
|
&ledger_path,
|
||||||
&genesis_config,
|
&genesis_config,
|
||||||
max_genesis_archive_unpacked_size,
|
max_genesis_archive_unpacked_size,
|
||||||
AccessType::PrimaryOnly,
|
|
||||||
BlockstoreAdvancedOptions::default(),
|
BlockstoreAdvancedOptions::default(),
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
|
|
|
@ -1723,7 +1723,6 @@ fn main() {
|
||||||
&output_directory,
|
&output_directory,
|
||||||
&genesis_config,
|
&genesis_config,
|
||||||
solana_runtime::hardened_unpack::MAX_GENESIS_ARCHIVE_UNPACKED_SIZE,
|
solana_runtime::hardened_unpack::MAX_GENESIS_ARCHIVE_UNPACKED_SIZE,
|
||||||
AccessType::PrimaryOnly,
|
|
||||||
BlockstoreAdvancedOptions::default(),
|
BlockstoreAdvancedOptions::default(),
|
||||||
)
|
)
|
||||||
.unwrap_or_else(|err| {
|
.unwrap_or_else(|err| {
|
||||||
|
|
|
@ -4150,7 +4150,6 @@ pub fn create_new_ledger(
|
||||||
ledger_path: &Path,
|
ledger_path: &Path,
|
||||||
genesis_config: &GenesisConfig,
|
genesis_config: &GenesisConfig,
|
||||||
max_genesis_archive_unpacked_size: u64,
|
max_genesis_archive_unpacked_size: u64,
|
||||||
access_type: AccessType,
|
|
||||||
advanced_options: BlockstoreAdvancedOptions,
|
advanced_options: BlockstoreAdvancedOptions,
|
||||||
) -> Result<Hash> {
|
) -> Result<Hash> {
|
||||||
Blockstore::destroy(ledger_path)?;
|
Blockstore::destroy(ledger_path)?;
|
||||||
|
@ -4161,7 +4160,7 @@ pub fn create_new_ledger(
|
||||||
let blockstore = Blockstore::open_with_options(
|
let blockstore = Blockstore::open_with_options(
|
||||||
ledger_path,
|
ledger_path,
|
||||||
BlockstoreOptions {
|
BlockstoreOptions {
|
||||||
access_type,
|
access_type: AccessType::PrimaryOnly,
|
||||||
recovery_mode: None,
|
recovery_mode: None,
|
||||||
enforce_ulimit_nofile: false,
|
enforce_ulimit_nofile: false,
|
||||||
advanced_options: advanced_options.clone(),
|
advanced_options: advanced_options.clone(),
|
||||||
|
@ -4333,7 +4332,6 @@ macro_rules! create_new_tmp_ledger {
|
||||||
$crate::blockstore::create_new_ledger_from_name(
|
$crate::blockstore::create_new_ledger_from_name(
|
||||||
$crate::tmp_ledger_name!(),
|
$crate::tmp_ledger_name!(),
|
||||||
$genesis_config,
|
$genesis_config,
|
||||||
$crate::blockstore_db::AccessType::PrimaryOnly,
|
|
||||||
$crate::blockstore_db::BlockstoreAdvancedOptions::default(),
|
$crate::blockstore_db::BlockstoreAdvancedOptions::default(),
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
@ -4345,7 +4343,6 @@ macro_rules! create_new_tmp_ledger_auto_delete {
|
||||||
$crate::blockstore::create_new_ledger_from_name_auto_delete(
|
$crate::blockstore::create_new_ledger_from_name_auto_delete(
|
||||||
$crate::tmp_ledger_name!(),
|
$crate::tmp_ledger_name!(),
|
||||||
$genesis_config,
|
$genesis_config,
|
||||||
$crate::blockstore_db::AccessType::PrimaryOnly,
|
|
||||||
$crate::blockstore_db::BlockstoreAdvancedOptions::default(),
|
$crate::blockstore_db::BlockstoreAdvancedOptions::default(),
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
@ -4357,7 +4354,6 @@ macro_rules! create_new_tmp_ledger_fifo_auto_delete {
|
||||||
$crate::blockstore::create_new_ledger_from_name_auto_delete(
|
$crate::blockstore::create_new_ledger_from_name_auto_delete(
|
||||||
$crate::tmp_ledger_name!(),
|
$crate::tmp_ledger_name!(),
|
||||||
$genesis_config,
|
$genesis_config,
|
||||||
$crate::blockstore_db::AccessType::PrimaryOnly,
|
|
||||||
$crate::blockstore_db::BlockstoreAdvancedOptions {
|
$crate::blockstore_db::BlockstoreAdvancedOptions {
|
||||||
shred_storage_type: $crate::blockstore_db::ShredStorageType::RocksFifo(
|
shred_storage_type: $crate::blockstore_db::ShredStorageType::RocksFifo(
|
||||||
$crate::blockstore_db::BlockstoreRocksFifoOptions::default(),
|
$crate::blockstore_db::BlockstoreRocksFifoOptions::default(),
|
||||||
|
@ -4392,15 +4388,10 @@ pub fn verify_shred_slots(slot: Slot, parent_slot: Slot, last_root: Slot) -> boo
|
||||||
pub fn create_new_ledger_from_name(
|
pub fn create_new_ledger_from_name(
|
||||||
name: &str,
|
name: &str,
|
||||||
genesis_config: &GenesisConfig,
|
genesis_config: &GenesisConfig,
|
||||||
access_type: AccessType,
|
|
||||||
advanced_options: BlockstoreAdvancedOptions,
|
advanced_options: BlockstoreAdvancedOptions,
|
||||||
) -> (PathBuf, Hash) {
|
) -> (PathBuf, Hash) {
|
||||||
let (ledger_path, blockhash) = create_new_ledger_from_name_auto_delete(
|
let (ledger_path, blockhash) =
|
||||||
name,
|
create_new_ledger_from_name_auto_delete(name, genesis_config, advanced_options);
|
||||||
genesis_config,
|
|
||||||
access_type,
|
|
||||||
advanced_options,
|
|
||||||
);
|
|
||||||
(ledger_path.into_path(), blockhash)
|
(ledger_path.into_path(), blockhash)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4411,7 +4402,6 @@ pub fn create_new_ledger_from_name(
|
||||||
pub fn create_new_ledger_from_name_auto_delete(
|
pub fn create_new_ledger_from_name_auto_delete(
|
||||||
name: &str,
|
name: &str,
|
||||||
genesis_config: &GenesisConfig,
|
genesis_config: &GenesisConfig,
|
||||||
access_type: AccessType,
|
|
||||||
advanced_options: BlockstoreAdvancedOptions,
|
advanced_options: BlockstoreAdvancedOptions,
|
||||||
) -> (TempDir, Hash) {
|
) -> (TempDir, Hash) {
|
||||||
let ledger_path = get_ledger_path_from_name_auto_delete(name);
|
let ledger_path = get_ledger_path_from_name_auto_delete(name);
|
||||||
|
@ -4419,7 +4409,6 @@ pub fn create_new_ledger_from_name_auto_delete(
|
||||||
ledger_path.path(),
|
ledger_path.path(),
|
||||||
genesis_config,
|
genesis_config,
|
||||||
MAX_GENESIS_ARCHIVE_UNPACKED_SIZE,
|
MAX_GENESIS_ARCHIVE_UNPACKED_SIZE,
|
||||||
access_type,
|
|
||||||
advanced_options,
|
advanced_options,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
|
@ -582,7 +582,6 @@ impl TestValidator {
|
||||||
config
|
config
|
||||||
.max_genesis_archive_unpacked_size
|
.max_genesis_archive_unpacked_size
|
||||||
.unwrap_or(MAX_GENESIS_ARCHIVE_UNPACKED_SIZE),
|
.unwrap_or(MAX_GENESIS_ARCHIVE_UNPACKED_SIZE),
|
||||||
solana_ledger::blockstore_db::AccessType::PrimaryOnly,
|
|
||||||
BlockstoreAdvancedOptions::default(),
|
BlockstoreAdvancedOptions::default(),
|
||||||
)
|
)
|
||||||
.map_err(|err| {
|
.map_err(|err| {
|
||||||
|
|
Loading…
Reference in New Issue