Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Consolidate repeated code in Rocks::open() #34131

Merged
merged 1 commit into from
Nov 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 23 additions & 30 deletions ledger/src/blockstore_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,46 +419,39 @@ impl Rocks {
}
let oldest_slot = OldestSlot::default();
let column_options = options.column_options.clone();
let cf_descriptors = Self::cf_descriptors(&options, &oldest_slot);

// Open the database
let db = match access_type {
AccessType::Primary | AccessType::PrimaryForMaintenance => Rocks {
db: DB::open_cf_descriptors(
&db_options,
path,
Self::cf_descriptors(&options, &oldest_slot),
)?,
access_type,
oldest_slot,
column_options,
write_batch_perf_status: PerfSamplingStatus::default(),
},
AccessType::Primary | AccessType::PrimaryForMaintenance => {
DB::open_cf_descriptors(&db_options, path, cf_descriptors)?
}
AccessType::Secondary => {
let secondary_path = path.join("solana-secondary");

info!(
"Opening Rocks with secondary (read only) access at: {:?}",
secondary_path
"Opening Rocks with secondary (read only) access at: {secondary_path:?}. \
This secondary access could temporarily degrade other accesses, such as \
by solana-validator"
);
info!("This secondary access could temporarily degrade other accesses, such as by solana-validator");

Rocks {
db: DB::open_cf_descriptors_as_secondary(
&db_options,
path,
&secondary_path,
Self::cf_descriptors(&options, &oldest_slot),
)?,
access_type,
oldest_slot,
column_options,
write_batch_perf_status: PerfSamplingStatus::default(),
}
DB::open_cf_descriptors_as_secondary(
&db_options,
path,
&secondary_path,
cf_descriptors,
)?
}
};
db.configure_compaction();
let rocks = Rocks {
db,
access_type,
oldest_slot,
column_options,
write_batch_perf_status: PerfSamplingStatus::default(),
};

rocks.configure_compaction();

Ok(db)
Ok(rocks)
}

fn cf_descriptors(
Expand Down