Struct solana_ledger::blockstore::Blockstore

source ·
pub struct Blockstore {
    pub shred_timing_point_sender: Option<PohTimingSender>,
    pub lowest_cleanup_slot: RwLock<Slot>,
    pub slots_stats: SlotsStats,
    /* private fields */
}

Fields§

§shred_timing_point_sender: Option<PohTimingSender>§lowest_cleanup_slot: RwLock<Slot>§slots_stats: SlotsStats

Implementations§

source§

impl Blockstore

source

pub fn purge_slots(&self, from_slot: Slot, to_slot: Slot, purge_type: PurgeType)

Performs cleanup based on the specified deletion range. After this function call, entries within [from_slot, to_slot] will become unavailable to the reader immediately, while its disk space occupied by the deletion entries are reclaimed later via RocksDB’s background compaction.

Note that this function modifies multiple column families at the same time and might break the consistency between different column families as it does not update the associated slot-meta entries that refer to the deleted entries.

For slot-id based column families, the purge is done by range deletion, while the non-slot-id based column families, cf::TransactionStatus, AddressSignature, and cf::TransactionStatusIndex, are cleaned-up based on the purge_type setting.

source

pub fn set_max_expired_slot(&self, to_slot: Slot)

Usually this is paired with .purge_slots() but we can’t internally call this in that function unconditionally. That’s because set_max_expired_slot() expects to purge older slots by the successive chronological order, while .purge_slots() can also be used to purge future slots for –hard-fork thing, preserving older slots. It’d be quite dangerous to purge older slots in that case. So, current legal user of this function is LedgerCleanupService.

source

pub fn purge_and_compact_slots(&self, from_slot: Slot, to_slot: Slot)

source

pub fn purge_from_next_slots(&self, from_slot: Slot, to_slot: Slot)

Ensures that the SlotMeta::next_slots vector for all slots contain no references in the [from_slot,to_slot] range

Dangerous; Use with care

source§

impl Blockstore

source

pub fn db(self) -> Arc<Database>

source

pub fn ledger_path(&self) -> &PathBuf

source

pub fn banking_trace_path(&self) -> PathBuf

source

pub fn open(ledger_path: &Path) -> Result<Blockstore>

Opens a Ledger in directory, provides “infinite” window of shreds

source

pub fn open_with_options( ledger_path: &Path, options: BlockstoreOptions ) -> Result<Blockstore>

source

pub fn open_with_signal( ledger_path: &Path, options: BlockstoreOptions ) -> Result<BlockstoreSignals>

source

pub fn add_tree( &self, forks: Tree<Slot>, is_orphan: bool, is_slot_complete: bool, num_ticks: u64, starting_hash: Hash )

source

pub fn destroy(ledger_path: &Path) -> Result<()>

Deletes the blockstore at the specified path.

Note that if the ledger_path has multiple rocksdb instances, this function will destroy all.

source

pub fn meta(&self, slot: Slot) -> Result<Option<SlotMeta>>

Returns the SlotMeta of the specified slot.

source

pub fn is_full(&self, slot: Slot) -> bool

Returns true if the specified slot is full.

source

pub fn orphan(&self, slot: Slot) -> Result<Option<bool>>

Check whether the specified slot is an orphan slot which does not have a parent slot.

Returns true if the specified slot does not have a parent slot. For other return values, it means either the slot is not in the blockstore or the slot isn’t an orphan slot.

source

pub fn slot_meta_iterator( &self, slot: Slot ) -> Result<impl Iterator<Item = (Slot, SlotMeta)> + '_>

source

pub fn live_slots_iterator( &self, root: Slot ) -> impl Iterator<Item = (Slot, SlotMeta)> + '_

source

pub fn live_files_metadata(&self) -> Result<Vec<LiveFile>>

source

pub fn slot_data_iterator( &self, slot: Slot, index: u64 ) -> Result<impl Iterator<Item = ((u64, u64), Box<[u8]>)> + '_>

source

pub fn slot_coding_iterator( &self, slot: Slot, index: u64 ) -> Result<impl Iterator<Item = ((u64, u64), Box<[u8]>)> + '_>

source

pub fn rooted_slot_iterator( &self, slot: Slot ) -> Result<impl Iterator<Item = Slot> + '_>

source

pub fn reversed_rooted_slot_iterator( &self, slot: Slot ) -> Result<impl Iterator<Item = Slot> + '_>

source

pub fn reversed_optimistic_slots_iterator( &self ) -> Result<impl Iterator<Item = (Slot, Hash, UnixTimestamp)> + '_>

source

pub fn slot_range_connected( &self, starting_slot: Slot, ending_slot: Slot ) -> bool

Determines if we can iterate from starting_slot to >= ending_slot by full slots starting_slot is excluded from the is_full() check

source

pub fn submit_rocksdb_cf_metrics_for_all_cfs(&self)

Collects and reports BlockstoreRocksDbColumnFamilyMetrics for the all the column families.

source

pub fn insert_shreds_handle_duplicate<F>( &self, shreds: Vec<Shred>, is_repaired: Vec<bool>, leader_schedule: Option<&LeaderScheduleCache>, is_trusted: bool, retransmit_sender: Option<&Sender<Vec<Vec<u8>>>>, handle_duplicate: &F, reed_solomon_cache: &ReedSolomonCache, metrics: &mut BlockstoreInsertionMetrics ) -> Result<Vec<CompletedDataSetInfo>>

source

pub fn add_new_shred_signal(&self, s: Sender<bool>)

source

pub fn add_completed_slots_signal(&self, s: CompletedSlotsSender)

source

pub fn get_new_shred_signals_len(&self) -> usize

source

pub fn get_new_shred_signal(&self, index: usize) -> Option<Sender<bool>>

source

pub fn drop_signal(&self)

source

pub fn clear_unconfirmed_slot(&self, slot: Slot)

Range-delete all entries which prefix matches the specified slot, remove slot its’ parents SlotMeta next_slots list, and clear slot’s SlotMeta (except for next_slots).

This function currently requires insert_shreds_lock, as both clear_unconfirmed_slot() and insert_shreds_handle_duplicate() try to perform read-modify-write operation on cf::SlotMeta column family.

source

pub fn insert_shreds( &self, shreds: Vec<Shred>, leader_schedule: Option<&LeaderScheduleCache>, is_trusted: bool ) -> Result<Vec<CompletedDataSetInfo>>

source

pub fn get_data_shred(&self, slot: Slot, index: u64) -> Result<Option<Vec<u8>>>

source

pub fn get_data_shreds_for_slot( &self, slot: Slot, start_index: u64 ) -> Result<Vec<Shred>>

source

pub fn get_coding_shred( &self, slot: Slot, index: u64 ) -> Result<Option<Vec<u8>>>

source

pub fn get_coding_shreds_for_slot( &self, slot: Slot, start_index: u64 ) -> Result<Vec<Shred>, Error>

source

pub fn get_index(&self, slot: Slot) -> Result<Option<Index>>

source

pub fn put_meta_bytes(&self, slot: Slot, bytes: &[u8]) -> Result<()>

Manually update the meta for a slot. Can interfere with automatic meta update and potentially break chaining. Dangerous. Use with care.

source

pub fn put_meta(&self, slot: Slot, meta: &SlotMeta) -> Result<()>

Manually update the meta for a slot. Can interfere with automatic meta update and potentially break chaining. Dangerous. Use with care.

source

pub fn find_missing_data_indexes( &self, slot: Slot, first_timestamp: u64, defer_threshold_ticks: u64, start_index: u64, end_index: u64, max_missing: usize ) -> Vec<u64>

Find missing data shreds for the given slot.

For more details on the arguments, see [find_missing_indexes].

source

pub fn get_rooted_block_time(&self, slot: Slot) -> Result<UnixTimestamp>

source

pub fn cache_block_time( &self, slot: Slot, timestamp: UnixTimestamp ) -> Result<()>

source

pub fn get_block_height(&self, slot: Slot) -> Result<Option<u64>>

source

pub fn cache_block_height(&self, slot: Slot, block_height: u64) -> Result<()>

source

pub fn get_first_available_block(&self) -> Result<Slot>

The first complete block that is available in the Blockstore ledger

source

pub fn get_rooted_block( &self, slot: Slot, require_previous_blockhash: bool ) -> Result<VersionedConfirmedBlock>

source

pub fn get_complete_block( &self, slot: Slot, require_previous_blockhash: bool ) -> Result<VersionedConfirmedBlock>

source

pub fn get_rooted_block_with_entries( &self, slot: Slot, require_previous_blockhash: bool ) -> Result<VersionedConfirmedBlockWithEntries>

source

pub fn map_transactions_to_statuses( &self, slot: Slot, iterator: impl Iterator<Item = VersionedTransaction> ) -> Result<Vec<VersionedTransactionWithStatusMeta>>

source

pub fn read_transaction_status( &self, index: (Signature, Slot) ) -> Result<Option<TransactionStatusMeta>>

source

pub fn write_transaction_status( &self, slot: Slot, signature: Signature, writable_keys: Vec<&Pubkey>, readonly_keys: Vec<&Pubkey>, status: TransactionStatusMeta, transaction_index: usize ) -> Result<()>

source

pub fn read_transaction_memos( &self, signature: Signature, slot: Slot ) -> Result<Option<String>>

source

pub fn write_transaction_memos( &self, signature: &Signature, slot: Slot, memos: String ) -> Result<()>

source

pub fn get_rooted_transaction_status( &self, signature: Signature ) -> Result<Option<(Slot, TransactionStatusMeta)>>

Returns a transaction status

source

pub fn get_transaction_status( &self, signature: Signature, confirmed_unrooted_slots: &HashSet<Slot> ) -> Result<Option<(Slot, TransactionStatusMeta)>>

Returns a transaction status

source

pub fn get_rooted_transaction( &self, signature: Signature ) -> Result<Option<ConfirmedTransactionWithStatusMeta>>

Returns a complete transaction if it was processed in a root

source

pub fn get_complete_transaction( &self, signature: Signature, highest_confirmed_slot: Slot ) -> Result<Option<ConfirmedTransactionWithStatusMeta>>

Returns a complete transaction

source

pub fn get_confirmed_signatures_for_address( &self, pubkey: Pubkey, start_slot: Slot, end_slot: Slot ) -> Result<Vec<Signature>>

source

pub fn get_confirmed_signatures_for_address2( &self, address: Pubkey, highest_slot: Slot, before: Option<Signature>, until: Option<Signature>, limit: usize ) -> Result<SignatureInfosForAddress>

source

pub fn read_rewards(&self, index: Slot) -> Result<Option<Rewards>>

source

pub fn write_rewards(&self, index: Slot, rewards: Rewards) -> Result<()>

source

pub fn get_recent_perf_samples( &self, num: usize ) -> Result<Vec<(Slot, PerfSample)>>

source

pub fn write_perf_sample( &self, index: Slot, perf_sample: &PerfSampleV2 ) -> Result<()>

source

pub fn read_program_costs(&self) -> Result<Vec<(Pubkey, u64)>>

source

pub fn write_program_cost(&self, key: &Pubkey, value: &u64) -> Result<()>

source

pub fn delete_program_cost(&self, key: &Pubkey) -> Result<()>

source

pub fn get_slot_entries( &self, slot: Slot, shred_start_index: u64 ) -> Result<Vec<Entry>>

Returns the entry vector for the slot starting with shred_start_index

source

pub fn get_slot_entries_with_shred_info( &self, slot: Slot, start_index: u64, allow_dead_slots: bool ) -> Result<(Vec<Entry>, u64, bool)>

Returns the entry vector for the slot starting with shred_start_index, the number of shreds that comprise the entry vector, and whether the slot is full (consumed all shreds).

source

pub fn get_accounts_used_in_range( &self, bank: &Bank, starting_slot: Slot, ending_slot: Slot ) -> (DashSet<Pubkey>, bool)

Gets accounts used in transactions in the slot range [starting_slot, ending_slot]. Additionally returns a bool indicating if the set may be incomplete. Used by ledger-tool to create a minimized snapshot

source

pub fn get_entries_in_data_block( &self, slot: Slot, start_index: u32, end_index: u32, slot_meta: Option<&SlotMeta> ) -> Result<Vec<Entry>>

source

pub fn get_slots_since( &self, slots: &[Slot] ) -> Result<HashMap<Slot, Vec<Slot>>>

Returns a mapping from each elements of slots to a list of the element’s children slots.

source

pub fn is_root(&self, slot: Slot) -> bool

source

pub fn is_skipped(&self, slot: Slot) -> bool

Returns true if a slot is between the rooted slot bounds of the ledger, but has not itself been rooted. This is either because the slot was skipped, or due to a gap in ledger data, as when booting from a newer snapshot.

source

pub fn insert_bank_hash( &self, slot: Slot, frozen_hash: Hash, is_duplicate_confirmed: bool )

source

pub fn get_bank_hash(&self, slot: Slot) -> Option<Hash>

source

pub fn is_duplicate_confirmed(&self, slot: Slot) -> bool

source

pub fn insert_optimistic_slot( &self, slot: Slot, hash: &Hash, timestamp: UnixTimestamp ) -> Result<()>

source

pub fn get_optimistic_slot( &self, slot: Slot ) -> Result<Option<(Hash, UnixTimestamp)>>

Returns information about a single optimistically confirmed slot

source

pub fn get_latest_optimistic_slots( &self, num: usize ) -> Result<Vec<(Slot, Hash, UnixTimestamp)>>

Returns information about the num latest optimistically confirmed slot

source

pub fn set_duplicate_confirmed_slots_and_hashes( &self, duplicate_confirmed_slot_hashes: impl Iterator<Item = (Slot, Hash)> ) -> Result<()>

source

pub fn set_roots<'a>( &self, rooted_slots: impl Iterator<Item = &'a Slot> ) -> Result<()>

source

pub fn mark_slots_as_if_rooted_normally_at_startup( &self, slots: Vec<(Slot, Option<Hash>)>, with_hash: bool ) -> Result<()>

source

pub fn is_dead(&self, slot: Slot) -> bool

source

pub fn set_dead_slot(&self, slot: Slot) -> Result<()>

source

pub fn remove_dead_slot(&self, slot: Slot) -> Result<()>

source

pub fn remove_slot_duplicate_proof(&self, slot: Slot) -> Result<()>

source

pub fn get_first_duplicate_proof(&self) -> Option<(Slot, DuplicateSlotProof)>

source

pub fn store_duplicate_slot( &self, slot: Slot, shred1: Vec<u8>, shred2: Vec<u8> ) -> Result<()>

source

pub fn get_duplicate_slot(&self, slot: u64) -> Option<DuplicateSlotProof>

source

pub fn is_shred_duplicate(&self, new_shred: &Shred) -> Option<Vec<u8>>

source

pub fn has_duplicate_shreds_in_slot(&self, slot: Slot) -> bool

source

pub fn orphans_iterator( &self, slot: Slot ) -> Result<impl Iterator<Item = u64> + '_>

source

pub fn dead_slots_iterator( &self, slot: Slot ) -> Result<impl Iterator<Item = Slot> + '_>

source

pub fn duplicate_slots_iterator( &self, slot: Slot ) -> Result<impl Iterator<Item = Slot> + '_>

source

pub fn max_root(&self) -> Slot

Returns the max root or 0 if it does not exist

source

pub fn last_root(&self) -> Slot

👎Deprecated since 1.18.0: Please use solana_ledger::blockstore::Blockstore::max_root() instead
source

pub fn lowest_slot(&self) -> Slot

source

pub fn highest_slot(&self) -> Result<Option<Slot>>

Returns the highest available slot in the blockstore

source

pub fn lowest_cleanup_slot(&self) -> Slot

source

pub fn storage_size(&self) -> Result<u64>

source

pub fn total_data_shred_storage_size(&self) -> Result<i64>

Returns the total physical storage size contributed by all data shreds.

Note that the reported size does not include those recently inserted shreds that are still in memory.

source

pub fn total_coding_shred_storage_size(&self) -> Result<i64>

Returns the total physical storage size contributed by all coding shreds.

Note that the reported size does not include those recently inserted shreds that are still in memory.

source

pub fn is_primary_access(&self) -> bool

Returns whether the blockstore has primary (read and write) access

source

pub fn scan_and_fix_roots( &self, start_root: Option<Slot>, end_slot: Option<Slot>, exit: &AtomicBool ) -> Result<usize>

Scan for any ancestors of the supplied start_root that are not marked as roots themselves. Mark any found slots as roots since the ancestor of a root is also inherently a root. Returns the number of slots that were actually updated.

Arguments:

  • start_root: The root to start scan from, or the highest root in the blockstore if this value is None. This slot must be a root.
  • end_slot``: The slot to stop the scan at; the scan will continue to the earliest slot in the Blockstore if this value is None`.
  • exit: Exit early if this flag is set to true.
source

pub fn set_and_chain_connected_on_root_and_next_slots( &self, root: Slot ) -> Result<()>

Mark a root slot as connected, traverse slot’s children and update the children’s connected status if appropriate.

A ledger with a full path of blocks from genesis to the latest root will have all of the rooted blocks marked as connected such that new blocks could also be connected. However, starting from some root (such as from a snapshot) is a valid way to join a cluster. For this case, mark this root as connected such that the node that joined midway through can have their slots considered connected.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> AbiExample for T

source§

default fn example() -> T

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

impl<T> IntoRequest<T> for T

source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> TupleTree<T, ()> for T

source§

const SIZE: Size = _

source§

fn descendants(_indirect_level: usize) -> usize

source§

fn height() -> usize

source§

fn preorder(self, f: &mut impl FnMut(Visit<T>))

source§

fn preorder_with_size_hint(self, f: &mut impl FnMut(Visit<T>, Size))

source§

fn postorder(self, f: &mut impl FnMut(Visit<T>))

source§

fn postorder_with_size_hint(self, f: &mut impl FnMut(Visit<T>, Size))

source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more