diff --git a/ledger/src/blockstore_db.rs b/ledger/src/blockstore_db.rs index 3b43c0079b5ea5..1b6d2a9ed39f4e 100644 --- a/ledger/src/blockstore_db.rs +++ b/ledger/src/blockstore_db.rs @@ -318,40 +318,18 @@ impl Rocks { new_cf_descriptor::(&access_type, &oldest_slot), new_cf_descriptor::(&access_type, &oldest_slot), new_cf_descriptor::(&access_type, &oldest_slot), - match options.shred_storage_type { - ShredStorageType::RocksLevel => { - new_cf_descriptor::(&access_type, &oldest_slot) - } - ShredStorageType::RocksFifo => { - if options.shred_data_cf_size > FIFO_WRITE_BUFFER_SIZE { - new_cf_descriptor_fifo::(&options.shred_data_cf_size) - } else { - warn!( - "shred_data_cf_size is must be greater than {} for RocksFifo.", - FIFO_WRITE_BUFFER_SIZE - ); - warn!("Fall back to ShredStorageType::RocksLevel for cf::ShredData."); - new_cf_descriptor::(&access_type, &oldest_slot) - } - } - }, - match options.shred_storage_type { - ShredStorageType::RocksLevel => { - new_cf_descriptor::(&access_type, &oldest_slot) - } - ShredStorageType::RocksFifo => { - if options.shred_code_cf_size > FIFO_WRITE_BUFFER_SIZE { - new_cf_descriptor_fifo::(&options.shred_code_cf_size) - } else { - warn!( - "shred_code_cf_size is must be greater than {} for RocksFifo.", - FIFO_WRITE_BUFFER_SIZE - ); - warn!("Fall back to ShredStorageType::RocksLevel for cf::ShredCode."); - new_cf_descriptor::(&access_type, &oldest_slot) - } - } - }, + new_cf_descriptor_shreds::( + &options.shred_storage_type, + &access_type, + &oldest_slot, + &options.shred_data_cf_size, + ), + new_cf_descriptor_shreds::( + &options.shred_storage_type, + &access_type, + &oldest_slot, + &options.shred_code_cf_size, + ), new_cf_descriptor::(&access_type, &oldest_slot), new_cf_descriptor::(&access_type, &oldest_slot), new_cf_descriptor::(&access_type, &oldest_slot), @@ -1437,6 +1415,35 @@ fn get_cf_options( options } +/// Constructs and returns a ColumnFamilyDescriptor based on the +/// specified ShredStorageType. +fn new_cf_descriptor_shreds( + storage_type: &ShredStorageType, + access_type: &AccessType, + oldest_slot: &OldestSlot, + max_cf_size: &u64, +) -> ColumnFamilyDescriptor { + match storage_type { + ShredStorageType::RocksLevel => new_cf_descriptor::(access_type, oldest_slot), + ShredStorageType::RocksFifo => { + if *max_cf_size > FIFO_WRITE_BUFFER_SIZE { + new_cf_descriptor_fifo::(max_cf_size) + } else { + warn!( + "{} cf_size must be greater than {} when using ShredStorageType::RocksFifo.", + C::NAME, + FIFO_WRITE_BUFFER_SIZE + ); + warn!( + "Fall back to ShredStorageType::RocksLevel for cf::{}.", + C::NAME + ); + new_cf_descriptor::(access_type, oldest_slot) + } + } + } +} + fn new_cf_descriptor_fifo( max_cf_size: &u64, ) -> ColumnFamilyDescriptor {