diff --git a/ledger/src/blockstore.rs b/ledger/src/blockstore.rs index eca79093ddeb0d..2894733e66cc8d 100644 --- a/ledger/src/blockstore.rs +++ b/ledger/src/blockstore.rs @@ -325,12 +325,6 @@ impl Blockstore { .unwrap_or(0); let last_root = RwLock::new(max_root); - // Initialize transaction status index if entries are not present - let initialize_transaction_status_index = db - .iter::(IteratorMode::Start)? - .next() - .is_none(); - measure.stop(); info!("{:?} {}", blockstore_path, measure); let blockstore = Blockstore { @@ -364,9 +358,8 @@ impl Blockstore { lowest_cleanup_slot: RwLock::::default(), slots_stats: SlotsStats::default(), }; - if initialize_transaction_status_index { - blockstore.initialize_transaction_status_index()?; - } + blockstore.cleanup_old_entries()?; + Ok(blockstore) } @@ -2109,16 +2102,10 @@ impl Blockstore { .collect() } - /// Initializes the TransactionStatusIndex column family with two records, `0` and `1`, - /// which are used as the primary index for entries in the TransactionStatus and - /// AddressSignatures columns. At any given time, one primary index is active (ie. new records - /// are stored under this index), the other is frozen. - fn initialize_transaction_status_index(&self) -> Result<()> { - self.transaction_status_index_cf - .put(0, &TransactionStatusIndexMeta::default())?; - self.transaction_status_index_cf - .put(1, &TransactionStatusIndexMeta::default())?; - + fn cleanup_old_entries(&self) -> Result<()> { + if !self.is_primary_access() { + return Ok(()); + } // If present, delete dummy entries inserted by old software // https://github.com/solana-labs/solana/blob/bc2b372/ledger/src/blockstore.rs#L2130-L2137 let transaction_status_dummy_key = cf::TransactionStatus::as_index(2); diff --git a/ledger/src/blockstore/blockstore_purge.rs b/ledger/src/blockstore/blockstore_purge.rs index b4e50234106bf0..edd35ba899fb58 100644 --- a/ledger/src/blockstore/blockstore_purge.rs +++ b/ledger/src/blockstore/blockstore_purge.rs @@ -761,7 +761,7 @@ pub mod tests { .transaction_status_index_cf .get(0) .unwrap() - .unwrap(); + .unwrap_or_default(); index0.frozen = true; index0.max_slot = 4; blockstore @@ -772,7 +772,7 @@ pub mod tests { .transaction_status_index_cf .get(1) .unwrap() - .unwrap(); + .unwrap_or_default(); index1.frozen = false; index1.max_slot = 9; blockstore