Skip to content
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
40 changes: 2 additions & 38 deletions accounts-db/src/storable_accounts.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
//! trait for abstracting underlying storage of pubkey and account pairs to be written
use {
crate::{
account_storage::meta::StoredAccountMeta, accounts_hash::AccountHash,
accounts_index::ZeroLamport,
},
crate::{account_storage::meta::StoredAccountMeta, accounts_index::ZeroLamport},
solana_sdk::{
account::{AccountSharedData, ReadableAccount},
clock::{Epoch, Slot},
Expand Down Expand Up @@ -135,19 +132,6 @@ pub trait StorableAccounts<'a>: Sync {
fn contains_multiple_slots(&self) -> bool {
false
}

/// true iff the impl can provide hash
/// Otherwise, hash has to be provided separately to store functions.
fn has_hash(&self) -> bool {
false
}

/// return hash for account at 'index'
/// Should only be called if 'has_hash' = true
fn hash(&self, _index: usize) -> &AccountHash {
// this should never be called if has_hash returns false
unimplemented!();
}
}

/// accounts that are moving from 'old_slot' to 'target_slot'
Expand Down Expand Up @@ -249,12 +233,6 @@ impl<'a> StorableAccounts<'a> for (Slot, &'a [&'a StoredAccountMeta<'a>]) {
fn len(&self) -> usize {
self.1.len()
}
fn has_hash(&self) -> bool {
true
}
fn hash(&self, index: usize) -> &AccountHash {
self.1[index].hash()
}
}

/// holds slices of accounts being moved FROM a common source slot to 'target_slot'
Expand Down Expand Up @@ -342,13 +320,6 @@ impl<'a> StorableAccounts<'a> for StorableAccountsBySlot<'a> {
fn contains_multiple_slots(&self) -> bool {
self.contains_multiple_slots
}
fn has_hash(&self) -> bool {
true
}
fn hash(&self, index: usize) -> &AccountHash {
let indexes = self.find_internal_index(index);
self.slots_and_accounts[indexes.0].1[indexes.1].hash()
}
}

/// this tuple contains a single different source slot that applies to all accounts
Expand All @@ -371,12 +342,6 @@ impl<'a> StorableAccounts<'a> for (Slot, &'a [&'a StoredAccountMeta<'a>], Slot)
fn len(&self) -> usize {
self.1.len()
}
fn has_hash(&self) -> bool {
true
}
fn hash(&self, index: usize) -> &AccountHash {
self.1[index].hash()
}
}

#[cfg(test)]
Expand All @@ -385,6 +350,7 @@ pub mod tests {
super::*,
crate::{
account_storage::meta::{AccountMeta, StoredAccountMeta, StoredMeta},
accounts_hash::AccountHash,
append_vec::AppendVecStoredAccountMeta,
},
solana_sdk::{
Expand Down Expand Up @@ -623,7 +589,6 @@ pub mod tests {
})
.collect::<Vec<_>>();
let storable = StorableAccountsBySlot::new(99, &slots_and_accounts[..]);
assert!(storable.has_hash());
assert_eq!(99, storable.target_slot());
assert_eq!(entries0 != entries, storable.contains_multiple_slots());
(0..entries).for_each(|index| {
Expand All @@ -632,7 +597,6 @@ pub mod tests {
assert!(accounts_equal(&account, &raw2[index]));
assert_eq!(account.pubkey(), raw2[index].pubkey());
});
assert_eq!(storable.hash(index), raw2[index].hash());
assert_eq!(storable.slot(index), expected_slots[index]);
})
}
Expand Down