Remove unused code in Blockstore underlying impl (#33538)
* Remove LedgerColumn::delete_slot() method * Remove primary_index() function from Trait column
This commit is contained in:
parent
402e9a5fff
commit
6b96a2259f
|
@ -677,12 +677,8 @@ pub trait Column {
|
|||
|
||||
fn key(index: Self::Index) -> Vec<u8>;
|
||||
fn index(key: &[u8]) -> Self::Index;
|
||||
// this return Slot or some u64
|
||||
fn primary_index(index: Self::Index) -> u64;
|
||||
fn as_index(slot: Slot) -> Self::Index;
|
||||
fn slot(index: Self::Index) -> Slot {
|
||||
Self::primary_index(index)
|
||||
}
|
||||
fn slot(index: Self::Index) -> Slot;
|
||||
}
|
||||
|
||||
pub trait ColumnName {
|
||||
|
@ -733,8 +729,7 @@ impl<T: SlotColumn> Column for T {
|
|||
BigEndian::read_u64(&key[..8])
|
||||
}
|
||||
|
||||
/// Obtains the primary index from the specified index.
|
||||
fn primary_index(index: u64) -> Slot {
|
||||
fn slot(index: Self::Index) -> Slot {
|
||||
index
|
||||
}
|
||||
|
||||
|
@ -766,10 +761,6 @@ impl Column for columns::TransactionStatus {
|
|||
}
|
||||
}
|
||||
|
||||
fn primary_index(index: Self::Index) -> u64 {
|
||||
index.0
|
||||
}
|
||||
|
||||
fn slot(index: Self::Index) -> Slot {
|
||||
index.2
|
||||
}
|
||||
|
@ -805,10 +796,6 @@ impl Column for columns::AddressSignatures {
|
|||
(index, pubkey, slot, signature)
|
||||
}
|
||||
|
||||
fn primary_index(index: Self::Index) -> u64 {
|
||||
index.0
|
||||
}
|
||||
|
||||
fn slot(index: Self::Index) -> Slot {
|
||||
index.2
|
||||
}
|
||||
|
@ -834,10 +821,6 @@ impl Column for columns::TransactionMemos {
|
|||
Signature::try_from(&key[..64]).unwrap()
|
||||
}
|
||||
|
||||
fn primary_index(_index: Self::Index) -> u64 {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn slot(_index: Self::Index) -> Slot {
|
||||
unimplemented!()
|
||||
}
|
||||
|
@ -863,10 +846,6 @@ impl Column for columns::TransactionStatusIndex {
|
|||
BigEndian::read_u64(&key[..8])
|
||||
}
|
||||
|
||||
fn primary_index(index: u64) -> u64 {
|
||||
index
|
||||
}
|
||||
|
||||
fn slot(_index: Self::Index) -> Slot {
|
||||
unimplemented!()
|
||||
}
|
||||
|
@ -927,10 +906,6 @@ impl Column for columns::ProgramCosts {
|
|||
Pubkey::try_from(&key[..32]).unwrap()
|
||||
}
|
||||
|
||||
fn primary_index(_index: Self::Index) -> u64 {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn slot(_index: Self::Index) -> Slot {
|
||||
unimplemented!()
|
||||
}
|
||||
|
@ -951,7 +926,7 @@ impl Column for columns::ShredCode {
|
|||
columns::ShredData::index(key)
|
||||
}
|
||||
|
||||
fn primary_index(index: Self::Index) -> Slot {
|
||||
fn slot(index: Self::Index) -> Slot {
|
||||
index.0
|
||||
}
|
||||
|
||||
|
@ -979,7 +954,7 @@ impl Column for columns::ShredData {
|
|||
(slot, index)
|
||||
}
|
||||
|
||||
fn primary_index(index: Self::Index) -> Slot {
|
||||
fn slot(index: Self::Index) -> Slot {
|
||||
index.0
|
||||
}
|
||||
|
||||
|
@ -1064,7 +1039,7 @@ impl Column for columns::ErasureMeta {
|
|||
key
|
||||
}
|
||||
|
||||
fn primary_index(index: Self::Index) -> Slot {
|
||||
fn slot(index: Self::Index) -> Slot {
|
||||
index.0
|
||||
}
|
||||
|
||||
|
@ -1375,40 +1350,6 @@ where
|
|||
}))
|
||||
}
|
||||
|
||||
pub fn delete_slot(
|
||||
&self,
|
||||
batch: &mut WriteBatch,
|
||||
from: Option<Slot>,
|
||||
to: Option<Slot>,
|
||||
) -> Result<bool>
|
||||
where
|
||||
C::Index: PartialOrd + Copy + ColumnName,
|
||||
{
|
||||
let mut end = true;
|
||||
let iter_config = match from {
|
||||
Some(s) => IteratorMode::From(C::as_index(s), IteratorDirection::Forward),
|
||||
None => IteratorMode::Start,
|
||||
};
|
||||
let iter = self.iter(iter_config)?;
|
||||
for (index, _) in iter {
|
||||
if let Some(to) = to {
|
||||
if C::primary_index(index) > to {
|
||||
end = false;
|
||||
break;
|
||||
}
|
||||
};
|
||||
if let Err(e) = batch.delete::<C>(index) {
|
||||
error!(
|
||||
"Error: {:?} while adding delete from_slot {:?} to batch {:?}",
|
||||
e,
|
||||
from,
|
||||
C::NAME
|
||||
)
|
||||
}
|
||||
}
|
||||
Ok(end)
|
||||
}
|
||||
|
||||
pub fn compact_range(&self, from: Slot, to: Slot) -> Result<bool>
|
||||
where
|
||||
C::Index: PartialOrd + Copy,
|
||||
|
|
Loading…
Reference in New Issue