Struct solana_ledger::blockstore::Blockstore
source · pub struct Blockstore {Show 29 fields
ledger_path: PathBuf,
db: Arc<Database>,
meta_cf: LedgerColumn<SlotMeta>,
dead_slots_cf: LedgerColumn<DeadSlots>,
duplicate_slots_cf: LedgerColumn<DuplicateSlots>,
erasure_meta_cf: LedgerColumn<ErasureMeta>,
orphans_cf: LedgerColumn<Orphans>,
index_cf: LedgerColumn<Index>,
data_shred_cf: LedgerColumn<ShredData>,
code_shred_cf: LedgerColumn<ShredCode>,
transaction_status_cf: LedgerColumn<TransactionStatus>,
address_signatures_cf: LedgerColumn<AddressSignatures>,
transaction_memos_cf: LedgerColumn<TransactionMemos>,
transaction_status_index_cf: LedgerColumn<TransactionStatusIndex>,
active_transaction_status_index: RwLock<u64>,
rewards_cf: LedgerColumn<Rewards>,
blocktime_cf: LedgerColumn<Blocktime>,
perf_samples_cf: LedgerColumn<PerfSamples>,
block_height_cf: LedgerColumn<BlockHeight>,
program_costs_cf: LedgerColumn<ProgramCosts>,
bank_hash_cf: LedgerColumn<BankHash>,
optimistic_slots_cf: LedgerColumn<OptimisticSlots>,
last_root: RwLock<Slot>,
insert_shreds_lock: Mutex<()>,
new_shreds_signals: Mutex<Vec<Sender<bool>>>,
completed_slots_senders: Mutex<Vec<CompletedSlotsSender>>,
pub shred_timing_point_sender: Option<PohTimingSender>,
pub lowest_cleanup_slot: RwLock<Slot>,
pub slots_stats: SlotsStats,
}
Fields§
§ledger_path: PathBuf
§db: Arc<Database>
§meta_cf: LedgerColumn<SlotMeta>
§dead_slots_cf: LedgerColumn<DeadSlots>
§duplicate_slots_cf: LedgerColumn<DuplicateSlots>
§erasure_meta_cf: LedgerColumn<ErasureMeta>
§orphans_cf: LedgerColumn<Orphans>
§index_cf: LedgerColumn<Index>
§data_shred_cf: LedgerColumn<ShredData>
§code_shred_cf: LedgerColumn<ShredCode>
§transaction_status_cf: LedgerColumn<TransactionStatus>
§address_signatures_cf: LedgerColumn<AddressSignatures>
§transaction_memos_cf: LedgerColumn<TransactionMemos>
§transaction_status_index_cf: LedgerColumn<TransactionStatusIndex>
§active_transaction_status_index: RwLock<u64>
§rewards_cf: LedgerColumn<Rewards>
§blocktime_cf: LedgerColumn<Blocktime>
§perf_samples_cf: LedgerColumn<PerfSamples>
§block_height_cf: LedgerColumn<BlockHeight>
§program_costs_cf: LedgerColumn<ProgramCosts>
§bank_hash_cf: LedgerColumn<BankHash>
§optimistic_slots_cf: LedgerColumn<OptimisticSlots>
§last_root: RwLock<Slot>
§insert_shreds_lock: Mutex<()>
§new_shreds_signals: Mutex<Vec<Sender<bool>>>
§completed_slots_senders: Mutex<Vec<CompletedSlotsSender>>
§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
pub(crate) fn run_purge( &self, from_slot: Slot, to_slot: Slot, purge_type: PurgeType ) -> Result<bool>
sourcepub(crate) fn run_purge_with_stats(
&self,
from_slot: Slot,
to_slot: Slot,
purge_type: PurgeType,
purge_stats: &mut PurgeStats
) -> Result<bool>
pub(crate) fn run_purge_with_stats( &self, from_slot: Slot, to_slot: Slot, purge_type: PurgeType, purge_stats: &mut PurgeStats ) -> Result<bool>
A helper function to purge_slots
that executes the ledger clean up.
The cleanup applies to [from_slot
, to_slot
].
When from_slot
is 0, any sst-file with a key-range completely older
than to_slot
will also be deleted.
fn purge_files_in_range(&self, from_slot: Slot, to_slot: Slot) -> bool
sourcefn purge_special_columns_exact(
&self,
batch: &mut WriteBatch<'_>,
from_slot: Slot,
to_slot: Slot
) -> Result<()>
fn purge_special_columns_exact( &self, batch: &mut WriteBatch<'_>, from_slot: Slot, to_slot: Slot ) -> Result<()>
Purges special columns (using a non-Slot primary-index) exactly, by deserializing each slot being purged and iterating through all transactions to determine the keys of individual records.
The purge range applies to [from_slot
, to_slot
].
This method is very slow.
sourcefn purge_special_columns_with_primary_index(
&self,
write_batch: &mut WriteBatch<'_>,
columns_purged: &mut bool,
w_active_transaction_status_index: &mut u64,
to_slot: Slot
) -> Result<()>
fn purge_special_columns_with_primary_index( &self, write_batch: &mut WriteBatch<'_>, columns_purged: &mut bool, w_active_transaction_status_index: &mut u64, to_slot: Slot ) -> Result<()>
Purges special columns (using a non-Slot primary-index) by range. Purge occurs if frozen primary index has a max-slot less than the highest slot being purged.
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>
fn do_open(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.
fn erasure_meta(&self, erasure_set: ErasureSetId) -> Result<Option<ErasureMeta>>
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]>)> + '_>
fn prepare_rooted_slot_iterator( &self, slot: Slot, direction: IteratorDirection ) -> Result<impl Iterator<Item = Slot> + '_>
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
fn get_recovery_data_shreds<'a>( index: &'a Index, slot: Slot, erasure_meta: &'a ErasureMeta, prev_inserted_shreds: &'a HashMap<ShredId, Shred>, data_cf: &'a LedgerColumn<ShredData> ) -> impl Iterator<Item = Shred> + 'a
fn get_recovery_coding_shreds<'a>( index: &'a Index, slot: Slot, erasure_meta: &'a ErasureMeta, prev_inserted_shreds: &'a HashMap<ShredId, Shred>, code_cf: &'a LedgerColumn<ShredCode> ) -> impl Iterator<Item = Shred> + 'a
fn recover_shreds( index: &mut Index, erasure_meta: &ErasureMeta, prev_inserted_shreds: &HashMap<ShredId, Shred>, recovered_shreds: &mut Vec<Shred>, data_cf: &LedgerColumn<ShredData>, code_cf: &LedgerColumn<ShredCode>, reed_solomon_cache: &ReedSolomonCache )
fn submit_metrics( slot: Slot, erasure_meta: &ErasureMeta, attempted: bool, status: String, recovered: usize )
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.
fn try_shred_recovery( db: &Database, erasure_metas: &HashMap<ErasureSetId, ErasureMeta>, index_working_set: &mut HashMap<u64, IndexMetaWorkingSetEntry>, prev_inserted_shreds: &HashMap<ShredId, Shred>, reed_solomon_cache: &ReedSolomonCache ) -> Vec<Shred>
sourcepub 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(Shred),
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(Shred),
The main helper function that performs the shred insertion logic and updates corresponding meta-data.
This function updates the following column families:
cf::DeadSlots
: mark a shred as “dead” if its meta-data indicates there is no need to replay this shred. Specifically when both the following conditions satisfy,- We get a new shred N marked as the last shred in the slot S, but N.index() is less than the current slot_meta.received for slot S.
- The slot is not currently full
It means there’s an alternate version of this slot. See
check_insert_data_shred
for more details.
cf::ShredData
: stores data shreds (in check_insert_data_shreds).cf::ShredCode
: stores coding shreds (in check_insert_coding_shreds).cf::SlotMeta
: the SlotMeta of the inputshreds
and their related shreds are updated. Specifically:handle_chaining()
updatescf::SlotMeta
in two ways. First, it updates the in-memory slot_meta_working_set, which will later be persisted in commit_slot_meta_working_set(). Second, for the newly chained slots (updated inside handle_chaining_for_slot()), it will directly persist their slot-meta intocf::SlotMeta
.- In
commit_slot_meta_working_set()
, persists everything stored in the in-memory structure slot_meta_working_set, which is updated by bothcheck_insert_data_shred()
andhandle_chaining()
.
cf::Orphans
: add or remove the ID of a slot tocf::Orphans
if it becomes / is no longer an orphan slot inhandle_chaining()
.cf::ErasureMeta
: the associated ErasureMeta of the coding and data shreds insideshreds
will be updated and committed tocf::ErasureMeta
.- pair to the
cf::Index
column family for each index_working_set_entry which insert did occur in this function call.
Arguments:
shreds
: the shreds to be inserted.is_repaired
: a boolean vector aligned withshreds
where each boolean indicates whether the corresponding shred is repaired or not.leader_schedule
: the leader scheduleis_trusted
: whether the shreds come from a trusted source. If this is set to true, then the function will skip the shred duplication and integrity checks.retransmit_sender
: the sender for transmitting any recovered data shreds.handle_duplicate
: a function for handling shreds that have the same slot and index.metrics
: the metric for reporting detailed stats
On success, the function returns an Ok result with a vector of
CompletedDataSetInfo
and a vector of its corresponding index in the
input shreds
vector.
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>>
fn check_insert_coding_shred<F>( &self, shred: Shred, erasure_metas: &mut HashMap<ErasureSetId, ErasureMeta>, index_working_set: &mut HashMap<u64, IndexMetaWorkingSetEntry>, write_batch: &mut WriteBatch<'_>, just_received_shreds: &mut HashMap<ShredId, Shred>, index_meta_time_us: &mut u64, handle_duplicate: &F, is_trusted: bool, shred_source: ShredSource, metrics: &mut BlockstoreInsertionMetrics ) -> boolwhere F: Fn(Shred),
fn find_conflicting_coding_shred( &self, shred: &Shred, slot: Slot, erasure_meta: &ErasureMeta, just_received_shreds: &HashMap<ShredId, Shred> ) -> Option<Vec<u8>>
sourcefn check_insert_data_shred<F>(
&self,
shred: Shred,
erasure_metas: &mut HashMap<ErasureSetId, ErasureMeta>,
index_working_set: &mut HashMap<u64, IndexMetaWorkingSetEntry>,
slot_meta_working_set: &mut HashMap<u64, SlotMetaWorkingSetEntry>,
write_batch: &mut WriteBatch<'_>,
just_inserted_shreds: &mut HashMap<ShredId, Shred>,
index_meta_time_us: &mut u64,
is_trusted: bool,
handle_duplicate: &F,
leader_schedule: Option<&LeaderScheduleCache>,
shred_source: ShredSource
) -> Result<Vec<CompletedDataSetInfo>, InsertDataShredError>where
F: Fn(Shred),
fn check_insert_data_shred<F>( &self, shred: Shred, erasure_metas: &mut HashMap<ErasureSetId, ErasureMeta>, index_working_set: &mut HashMap<u64, IndexMetaWorkingSetEntry>, slot_meta_working_set: &mut HashMap<u64, SlotMetaWorkingSetEntry>, write_batch: &mut WriteBatch<'_>, just_inserted_shreds: &mut HashMap<ShredId, Shred>, index_meta_time_us: &mut u64, is_trusted: bool, handle_duplicate: &F, leader_schedule: Option<&LeaderScheduleCache>, shred_source: ShredSource ) -> Result<Vec<CompletedDataSetInfo>, InsertDataShredError>where F: Fn(Shred),
Create an entry to the specified write_batch
that performs shred
insertion and associated metadata update. The function also updates
its in-memory copy of the associated metadata.
Currently, this function must be invoked while holding
insert_shreds_lock
as it performs read-modify-write operations
on multiple column families.
The resulting write_batch
may include updates to cf::DeadSlots
and cf::ShredData
. Note that it will also update the in-memory copy
of erasure_metas
and index_working_set
, which will later be
used to update other column families such as cf::ErasureMeta
and
cf::Index
.
Arguments:
shred
: the shred to be insertederasure_metas
: the in-memory hash-map that maintains the dirty copy of the erasure meta. It will later be written tocf::ErasureMeta
in insert_shreds_handle_duplicate().index_working_set
: the in-memory hash-map that maintains the dirty copy of the index meta. It will later be written tocf::Index
in insert_shreds_handle_duplicate().slot_meta_working_set
: the in-memory hash-map that maintains the dirty copy of the index meta. It will later be written tocf::SlotMeta
in insert_shreds_handle_duplicate().write_batch
: the collection of the current writes which will be committed atomically.just_inserted_data_shreds
: a (slot, shred index within the slot) to shred map which maintains which data shreds have been inserted.index_meta_time_us
: the time spent on loading or creating the index meta entry from the db.is_trusted
: if false, this function will check whether the input shred is duplicate.handle_duplicate
: the function that handles duplication.leader_schedule
: the leader schedule will be used to check whether it is okay to insert the input shred.shred_source
: the source of the shred.
fn should_insert_coding_shred(shred: &Shred, last_root: &RwLock<u64>) -> bool
fn insert_coding_shred( &self, index_meta: &mut Index, shred: &Shred, write_batch: &mut WriteBatch<'_> ) -> Result<()>
fn is_data_shred_present( shred: &Shred, slot_meta: &SlotMeta, data_index: &ShredIndex ) -> bool
fn get_data_shred_from_just_inserted_or_db<'a>( &'a self, just_inserted_shreds: &'a HashMap<ShredId, Shred>, slot: Slot, index: u64 ) -> Cow<'a, Vec<u8>>
fn should_insert_data_shred( &self, shred: &Shred, slot_meta: &SlotMeta, just_inserted_shreds: &HashMap<ShredId, Shred>, last_root: &RwLock<u64>, leader_schedule: Option<&LeaderScheduleCache>, shred_source: ShredSource ) -> bool
sourcefn send_slot_full_timing(&self, slot: Slot)
fn send_slot_full_timing(&self, slot: Slot)
send slot full timing point to poh_timing_report service
fn insert_data_shred( &self, slot_meta: &mut SlotMeta, data_index: &mut ShredIndex, shred: &Shred, write_batch: &mut WriteBatch<'_>, shred_source: ShredSource ) -> 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>, Error>
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(crate) fn write_entries( &self, start_slot: Slot, num_ticks_in_start_slot: u64, start_index: u32, ticks_per_slot: u64, parent: Option<u64>, is_full_slot: bool, keypair: &Keypair, entries: Vec<Entry>, version: u16 ) -> Result<usize>
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.
fn find_missing_indexes<C>( db_iterator: &mut DBRawIterator<'_>, slot: Slot, first_timestamp: u64, defer_threshold_ticks: u64, start_index: u64, end_index: u64, max_missing: usize ) -> Vec<u64>where C: Column<Index = (u64, 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>
pub fn get_block_time(&self, slot: Slot) -> Result<Option<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 map_transactions_to_statuses( &self, slot: Slot, iterator: impl Iterator<Item = VersionedTransaction> ) -> Result<Vec<VersionedTransactionWithStatusMeta>>
sourcefn initialize_transaction_status_index(&self) -> Result<()>
fn initialize_transaction_status_index(&self) -> Result<()>
Initializes the TransactionStatusIndex column family with two records, 0
and 1
,
which are used as the primary index for entries in the TransactionStatus and
AddressSignatures columns. At any given time, one primary index is active (ie. new records
are stored under this index), the other is frozen.
sourcefn toggle_transaction_status_index(
&self,
batch: &mut WriteBatch<'_>,
w_active_transaction_status_index: &mut u64,
to_slot: Slot
) -> Result<Option<u64>>
fn toggle_transaction_status_index( &self, batch: &mut WriteBatch<'_>, w_active_transaction_status_index: &mut u64, to_slot: Slot ) -> Result<Option<u64>>
Toggles the active primary index between 0
and 1
, and clears the
stored max-slot of the frozen index in preparation for pruning.
fn get_primary_index_to_write( &self, slot: Slot, w_active_transaction_status_index: &RwLockWriteGuard<'_, Slot> ) -> Result<u64>
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 ) -> Result<()>
pub fn read_transaction_memos( &self, signature: Signature ) -> Result<Option<String>>
pub fn write_transaction_memos( &self, signature: &Signature, memos: String ) -> Result<()>
sourcefn check_lowest_cleanup_slot(
&self,
slot: Slot
) -> Result<RwLockReadGuard<'_, Slot>>
fn check_lowest_cleanup_slot( &self, slot: Slot ) -> Result<RwLockReadGuard<'_, Slot>>
Acquires the lowest_cleanup_slot
lock and returns a tuple of the held lock
and lowest available slot.
The function will return BlockstoreError::SlotCleanedUp if the input
slot
has already been cleaned-up.
sourcefn ensure_lowest_cleanup_slot(&self) -> (RwLockReadGuard<'_, Slot>, Slot)
fn ensure_lowest_cleanup_slot(&self) -> (RwLockReadGuard<'_, Slot>, Slot)
Acquires the lock of lowest_cleanup_slot
and returns the tuple of
the held lock and the lowest available slot.
This function ensures a consistent result by using lowest_cleanup_slot as the lower bound for reading columns that do not employ strong read consistency with slot-based delete_range.
fn get_transaction_status_with_counter( &self, signature: Signature, confirmed_unrooted_slots: &[Slot] ) -> Result<(Option<(Slot, TransactionStatusMeta)>, u64)>
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: &[Slot]
) -> Result<Option<(Slot, TransactionStatusMeta)>>
pub fn get_transaction_status( &self, signature: Signature, confirmed_unrooted_slots: &[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
fn get_transaction_with_status( &self, signature: Signature, confirmed_unrooted_slots: &[Slot] ) -> Result<Option<ConfirmedTransactionWithStatusMeta>>
fn find_transaction_in_slot( &self, slot: Slot, signature: Signature ) -> Result<Option<VersionedTransaction>>
fn find_address_signatures( &self, pubkey: Pubkey, start_slot: Slot, end_slot: Slot ) -> Result<Vec<(Slot, Signature)>>
fn find_address_signatures_for_slot( &self, pubkey: Pubkey, slot: Slot ) -> Result<Vec<(Slot, Signature)>>
pub fn get_confirmed_signatures_for_address( &self, pubkey: Pubkey, start_slot: Slot, end_slot: Slot ) -> Result<Vec<Signature>>
fn get_sorted_block_signatures(&self, 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>
pub fn get_accounts_used_in_range( &self, bank: &Bank, starting_slot: Slot, ending_slot: Slot ) -> DashSet<Pubkey>
Gets accounts used in transactions in the slot range [starting_slot, ending_slot]. Used by ledger-tool to create a minimized snapshot
fn get_completed_ranges( &self, slot: Slot, start_index: u64 ) -> Result<(Vec<(u32, u32)>, Option<SlotMeta>)>
fn get_completed_data_ranges( start_index: u32, completed_data_indexes: &BTreeSet<u32>, consumed: u32 ) -> Vec<(u32, u32)>
pub fn get_entries_in_data_block( &self, slot: Slot, start_index: u32, end_index: u32, slot_meta: Option<&SlotMeta> ) -> Result<Vec<Entry>>
fn get_any_valid_slot_entries(&self, slot: Slot, start_index: u64) -> 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<()>
pub fn get_latest_optimistic_slots( &self, num: usize ) -> Result<Vec<(Slot, Hash, UnixTimestamp)>>
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 store_duplicate_if_not_existing( &self, slot: Slot, shred1: Vec<u8>, shred2: Vec<u8> ) -> Result<()>
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, shred: ShredId, payload: Vec<u8> ) -> 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
pub fn lowest_slot(&self) -> Slot
fn lowest_slot_with_genesis(&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
pub fn scan_and_fix_roots(&self, exit: &AtomicBool) -> Result<()>
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 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> 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