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
impl Blockstore
sourcepub fn purge_slots(&self, from_slot: Slot, to_slot: Slot, purge_type: PurgeType)
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.
sourcepub fn set_max_expired_slot(&self, to_slot: Slot)
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.
pub fn purge_and_compact_slots(&self, from_slot: Slot, to_slot: Slot)
sourcepub fn purge_from_next_slots(&self, from_slot: Slot, to_slot: Slot)
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
impl Blockstore
pub fn db(self) -> Arc<Database>
pub fn ledger_path(&self) -> &PathBuf
pub fn banking_trace_path(&self) -> PathBuf
sourcepub fn open(ledger_path: &Path) -> Result<Blockstore>
pub fn open(ledger_path: &Path) -> Result<Blockstore>
Opens a Ledger in directory, provides “infinite” window of shreds
pub fn open_with_options( ledger_path: &Path, options: BlockstoreOptions ) -> Result<Blockstore>
pub fn open_with_signal( ledger_path: &Path, options: BlockstoreOptions ) -> Result<BlockstoreSignals>
pub fn add_tree( &self, forks: Tree<Slot>, is_orphan: bool, is_slot_complete: bool, num_ticks: u64, starting_hash: Hash )
sourcepub fn destroy(ledger_path: &Path) -> Result<()>
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.
sourcepub fn meta(&self, slot: Slot) -> Result<Option<SlotMeta>>
pub fn meta(&self, slot: Slot) -> Result<Option<SlotMeta>>
Returns the SlotMeta of the specified slot.
sourcepub fn orphan(&self, slot: Slot) -> Result<Option<bool>>
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.
pub fn slot_meta_iterator( &self, slot: Slot ) -> Result<impl Iterator<Item = (Slot, SlotMeta)> + '_>
pub fn live_slots_iterator( &self, root: Slot ) -> impl Iterator<Item = (Slot, SlotMeta)> + '_
pub fn live_files_metadata(&self) -> Result<Vec<LiveFile>>
pub fn slot_data_iterator( &self, slot: Slot, index: u64 ) -> Result<impl Iterator<Item = ((u64, u64), Box<[u8]>)> + '_>
pub fn slot_coding_iterator( &self, slot: Slot, index: u64 ) -> Result<impl Iterator<Item = ((u64, u64), Box<[u8]>)> + '_>
pub fn rooted_slot_iterator( &self, slot: Slot ) -> Result<impl Iterator<Item = Slot> + '_>
pub fn reversed_rooted_slot_iterator( &self, slot: Slot ) -> Result<impl Iterator<Item = Slot> + '_>
pub fn reversed_optimistic_slots_iterator( &self ) -> Result<impl Iterator<Item = (Slot, Hash, UnixTimestamp)> + '_>
sourcepub fn slot_range_connected(
&self,
starting_slot: Slot,
ending_slot: Slot
) -> bool
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
sourcepub fn submit_rocksdb_cf_metrics_for_all_cfs(&self)
pub fn submit_rocksdb_cf_metrics_for_all_cfs(&self)
Collects and reports BlockstoreRocksDbColumnFamilyMetrics
for the
all the column families.
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>>where
F: Fn(PossibleDuplicateShred),
pub fn add_new_shred_signal(&self, s: Sender<bool>)
pub fn add_completed_slots_signal(&self, s: CompletedSlotsSender)
pub fn get_new_shred_signals_len(&self) -> usize
pub fn get_new_shred_signal(&self, index: usize) -> Option<Sender<bool>>
pub fn drop_signal(&self)
sourcepub fn clear_unconfirmed_slot(&self, slot: Slot)
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.
pub fn insert_shreds( &self, shreds: Vec<Shred>, leader_schedule: Option<&LeaderScheduleCache>, is_trusted: bool ) -> Result<Vec<CompletedDataSetInfo>>
pub fn get_data_shred(&self, slot: Slot, index: u64) -> Result<Option<Vec<u8>>>
pub fn get_data_shreds_for_slot( &self, slot: Slot, start_index: u64 ) -> Result<Vec<Shred>>
pub fn get_coding_shred( &self, slot: Slot, index: u64 ) -> Result<Option<Vec<u8>>>
pub fn get_coding_shreds_for_slot( &self, slot: Slot, start_index: u64 ) -> Result<Vec<Shred>, Error>
pub fn get_index(&self, slot: Slot) -> Result<Option<Index>>
sourcepub fn put_meta_bytes(&self, slot: Slot, bytes: &[u8]) -> Result<()>
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.
sourcepub fn put_meta(&self, slot: Slot, meta: &SlotMeta) -> Result<()>
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.
sourcepub 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>
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
].
pub fn get_rooted_block_time(&self, slot: Slot) -> Result<UnixTimestamp>
pub fn cache_block_time( &self, slot: Slot, timestamp: UnixTimestamp ) -> Result<()>
pub fn get_block_height(&self, slot: Slot) -> Result<Option<u64>>
pub fn cache_block_height(&self, slot: Slot, block_height: u64) -> Result<()>
sourcepub fn get_first_available_block(&self) -> Result<Slot>
pub fn get_first_available_block(&self) -> Result<Slot>
The first complete block that is available in the Blockstore ledger
pub fn get_rooted_block( &self, slot: Slot, require_previous_blockhash: bool ) -> Result<VersionedConfirmedBlock>
pub fn get_complete_block( &self, slot: Slot, require_previous_blockhash: bool ) -> Result<VersionedConfirmedBlock>
pub fn get_rooted_block_with_entries( &self, slot: Slot, require_previous_blockhash: bool ) -> Result<VersionedConfirmedBlockWithEntries>
pub fn map_transactions_to_statuses( &self, slot: Slot, iterator: impl Iterator<Item = VersionedTransaction> ) -> Result<Vec<VersionedTransactionWithStatusMeta>>
pub fn read_transaction_status( &self, index: (Signature, Slot) ) -> Result<Option<TransactionStatusMeta>>
pub fn write_transaction_status( &self, slot: Slot, signature: Signature, writable_keys: Vec<&Pubkey>, readonly_keys: Vec<&Pubkey>, status: TransactionStatusMeta, transaction_index: usize ) -> Result<()>
pub fn read_transaction_memos( &self, signature: Signature, slot: Slot ) -> Result<Option<String>>
pub fn write_transaction_memos( &self, signature: &Signature, slot: Slot, memos: String ) -> Result<()>
sourcepub fn get_rooted_transaction_status(
&self,
signature: Signature
) -> Result<Option<(Slot, TransactionStatusMeta)>>
pub fn get_rooted_transaction_status( &self, signature: Signature ) -> Result<Option<(Slot, TransactionStatusMeta)>>
Returns a transaction status
sourcepub fn get_transaction_status(
&self,
signature: Signature,
confirmed_unrooted_slots: &HashSet<Slot>
) -> Result<Option<(Slot, TransactionStatusMeta)>>
pub fn get_transaction_status( &self, signature: Signature, confirmed_unrooted_slots: &HashSet<Slot> ) -> Result<Option<(Slot, TransactionStatusMeta)>>
Returns a transaction status
sourcepub fn get_rooted_transaction(
&self,
signature: Signature
) -> Result<Option<ConfirmedTransactionWithStatusMeta>>
pub fn get_rooted_transaction( &self, signature: Signature ) -> Result<Option<ConfirmedTransactionWithStatusMeta>>
Returns a complete transaction if it was processed in a root
sourcepub fn get_complete_transaction(
&self,
signature: Signature,
highest_confirmed_slot: Slot
) -> Result<Option<ConfirmedTransactionWithStatusMeta>>
pub fn get_complete_transaction( &self, signature: Signature, highest_confirmed_slot: Slot ) -> Result<Option<ConfirmedTransactionWithStatusMeta>>
Returns a complete transaction
pub fn get_confirmed_signatures_for_address( &self, pubkey: Pubkey, start_slot: Slot, end_slot: Slot ) -> Result<Vec<Signature>>
pub fn get_confirmed_signatures_for_address2( &self, address: Pubkey, highest_slot: Slot, before: Option<Signature>, until: Option<Signature>, limit: usize ) -> Result<SignatureInfosForAddress>
pub fn read_rewards(&self, index: Slot) -> Result<Option<Rewards>>
pub fn write_rewards(&self, index: Slot, rewards: Rewards) -> Result<()>
pub fn get_recent_perf_samples( &self, num: usize ) -> Result<Vec<(Slot, PerfSample)>>
pub fn write_perf_sample( &self, index: Slot, perf_sample: &PerfSampleV2 ) -> Result<()>
pub fn read_program_costs(&self) -> Result<Vec<(Pubkey, u64)>>
pub fn write_program_cost(&self, key: &Pubkey, value: &u64) -> Result<()>
pub fn delete_program_cost(&self, key: &Pubkey) -> Result<()>
sourcepub fn get_slot_entries(
&self,
slot: Slot,
shred_start_index: u64
) -> Result<Vec<Entry>>
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
sourcepub fn get_slot_entries_with_shred_info(
&self,
slot: Slot,
start_index: u64,
allow_dead_slots: bool
) -> Result<(Vec<Entry>, u64, bool)>
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).
sourcepub fn get_accounts_used_in_range(
&self,
bank: &Bank,
starting_slot: Slot,
ending_slot: Slot
) -> (DashSet<Pubkey>, bool)
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
pub fn get_entries_in_data_block( &self, slot: Slot, start_index: u32, end_index: u32, slot_meta: Option<&SlotMeta> ) -> Result<Vec<Entry>>
sourcepub fn get_slots_since(
&self,
slots: &[Slot]
) -> Result<HashMap<Slot, Vec<Slot>>>
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.
pub fn is_root(&self, slot: Slot) -> bool
sourcepub fn is_skipped(&self, slot: Slot) -> bool
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.
pub fn insert_bank_hash( &self, slot: Slot, frozen_hash: Hash, is_duplicate_confirmed: bool )
pub fn get_bank_hash(&self, slot: Slot) -> Option<Hash>
pub fn is_duplicate_confirmed(&self, slot: Slot) -> bool
pub fn insert_optimistic_slot( &self, slot: Slot, hash: &Hash, timestamp: UnixTimestamp ) -> Result<()>
sourcepub fn get_optimistic_slot(
&self,
slot: Slot
) -> Result<Option<(Hash, UnixTimestamp)>>
pub fn get_optimistic_slot( &self, slot: Slot ) -> Result<Option<(Hash, UnixTimestamp)>>
Returns information about a single optimistically confirmed slot
sourcepub fn get_latest_optimistic_slots(
&self,
num: usize
) -> Result<Vec<(Slot, Hash, UnixTimestamp)>>
pub fn get_latest_optimistic_slots( &self, num: usize ) -> Result<Vec<(Slot, Hash, UnixTimestamp)>>
Returns information about the num
latest optimistically confirmed slot
pub fn set_duplicate_confirmed_slots_and_hashes( &self, duplicate_confirmed_slot_hashes: impl Iterator<Item = (Slot, Hash)> ) -> Result<()>
pub fn set_roots<'a>( &self, rooted_slots: impl Iterator<Item = &'a Slot> ) -> Result<()>
pub fn mark_slots_as_if_rooted_normally_at_startup( &self, slots: Vec<(Slot, Option<Hash>)>, with_hash: bool ) -> Result<()>
pub fn is_dead(&self, slot: Slot) -> bool
pub fn set_dead_slot(&self, slot: Slot) -> Result<()>
pub fn remove_dead_slot(&self, slot: Slot) -> Result<()>
pub fn remove_slot_duplicate_proof(&self, slot: Slot) -> Result<()>
pub fn get_first_duplicate_proof(&self) -> Option<(Slot, DuplicateSlotProof)>
pub fn store_duplicate_slot( &self, slot: Slot, shred1: Vec<u8>, shred2: Vec<u8> ) -> Result<()>
pub fn get_duplicate_slot(&self, slot: u64) -> Option<DuplicateSlotProof>
pub fn is_shred_duplicate(&self, new_shred: &Shred) -> Option<Vec<u8>>
pub fn has_duplicate_shreds_in_slot(&self, slot: Slot) -> bool
pub fn orphans_iterator( &self, slot: Slot ) -> Result<impl Iterator<Item = u64> + '_>
pub fn dead_slots_iterator( &self, slot: Slot ) -> Result<impl Iterator<Item = Slot> + '_>
pub fn duplicate_slots_iterator( &self, slot: Slot ) -> Result<impl Iterator<Item = Slot> + '_>
pub fn last_root(&self) -> Slot
solana_ledger::blockstore::Blockstore::max_root()
insteadpub fn lowest_slot(&self) -> Slot
sourcepub fn highest_slot(&self) -> Result<Option<Slot>>
pub fn highest_slot(&self) -> Result<Option<Slot>>
Returns the highest available slot in the blockstore
pub fn lowest_cleanup_slot(&self) -> Slot
pub fn storage_size(&self) -> Result<u64>
sourcepub fn total_data_shred_storage_size(&self) -> Result<i64>
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.
sourcepub fn total_coding_shred_storage_size(&self) -> Result<i64>
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.
sourcepub fn is_primary_access(&self) -> bool
pub fn is_primary_access(&self) -> bool
Returns whether the blockstore has primary (read and write) access
sourcepub fn scan_and_fix_roots(
&self,
start_root: Option<Slot>,
end_slot: Option<Slot>,
exit: &AtomicBool
) -> Result<usize>
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 isNone
. 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 totrue
.
sourcepub fn set_and_chain_connected_on_root_and_next_slots(
&self,
root: Slot
) -> Result<()>
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§
impl !Freeze for Blockstore
impl RefUnwindSafe for Blockstore
impl Send for Blockstore
impl Sync for Blockstore
impl Unpin for Blockstore
impl UnwindSafe for Blockstore
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moresource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request