diff --git a/ledger/src/blockstore/blockstore_purge.rs b/ledger/src/blockstore/blockstore_purge.rs index 7a58d7875..090096d17 100644 --- a/ledger/src/blockstore/blockstore_purge.rs +++ b/ledger/src/blockstore/blockstore_purge.rs @@ -354,8 +354,7 @@ impl Blockstore { ) -> Result<()> { let mut index0 = self.transaction_status_index_cf.get(0)?.unwrap_or_default(); let mut index1 = self.transaction_status_index_cf.get(1)?.unwrap_or_default(); - let to_slot = to_slot.saturating_add(1); - for slot in from_slot..to_slot { + for slot in from_slot..=to_slot { let slot_entries = self.get_any_valid_slot_entries(slot, 0); let transactions = slot_entries .into_iter() @@ -1100,6 +1099,27 @@ pub mod tests { assert_eq!(entry.0, 2); // Buffer entry, no index 1 entries remaining drop(status_entry_iterator); + // Purge up to but not including index0_max_slot + clear_and_repopulate_transaction_statuses_for_test( + &blockstore, + index0_max_slot, + index1_max_slot, + ); + blockstore + .run_purge(0, index0_max_slot - 1, PurgeType::Exact) + .unwrap(); + assert_eq!( + blockstore + .transaction_status_index_cf + .get(0) + .unwrap() + .unwrap(), + TransactionStatusIndexMeta { + max_slot: index0_max_slot, + frozen: true, + } + ); + // Test purge all clear_and_repopulate_transaction_statuses_for_test( &blockstore,