Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unused code in Blockstore underlying impl #33538

Merged
merged 2 commits into from
Oct 5, 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
69 changes: 5 additions & 64 deletions ledger/src/blockstore_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -663,12 +663,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 {
Expand Down Expand Up @@ -719,8 +715,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
}

Expand Down Expand Up @@ -752,10 +747,6 @@ impl Column for columns::TransactionStatus {
}
}

fn primary_index(index: Self::Index) -> u64 {
index.0
}

fn slot(index: Self::Index) -> Slot {
index.2
}
Expand Down Expand Up @@ -791,10 +782,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
}
Expand All @@ -820,10 +807,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!()
}
Expand All @@ -849,10 +832,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!()
}
Expand Down Expand Up @@ -913,10 +892,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!()
}
Expand All @@ -937,7 +912,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
}

Expand Down Expand Up @@ -965,7 +940,7 @@ impl Column for columns::ShredData {
(slot, index)
}

fn primary_index(index: Self::Index) -> Slot {
fn slot(index: Self::Index) -> Slot {
index.0
}

Expand Down Expand Up @@ -1050,7 +1025,7 @@ impl Column for columns::ErasureMeta {
key
}

fn primary_index(index: Self::Index) -> Slot {
fn slot(index: Self::Index) -> Slot {
index.0
}

Expand Down Expand Up @@ -1361,40 +1336,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,
Expand Down