Skip to main content

Bank

Struct Bank 

Source
pub struct Bank {
    pub rc: BankRc,
    pub status_cache: Arc<RwLock<BankStatusCache>>,
    pub ancestors: Ancestors,
    pub ns_per_slot: u128,
    pub rewards: RwLock<Vec<(Pubkey, RewardInfo)>>,
    pub cluster_type: Option<ClusterType>,
    pub transaction_log_collector_config: Arc<RwLock<TransactionLogCollectorConfig>>,
    pub transaction_log_collector: Arc<RwLock<TransactionLogCollector>>,
    pub feature_set: Arc<FeatureSet>,
    pub drop_callback: RwLock<OptionalDropCallback>,
    pub freeze_started: AtomicBool,
    pub block_component_processor: RwLock<BlockComponentProcessor>,
    /* private fields */
}
Expand description

Manager for the state of all accounts and programs after processing its entries.

Fields§

§rc: BankRc

References to accounts, parent and signature status

§status_cache: Arc<RwLock<BankStatusCache>>

A cache of signature statuses

§ancestors: Ancestors

The set of parents including this bank

§ns_per_slot: u128

length of a slot in ns

§rewards: RwLock<Vec<(Pubkey, RewardInfo)>>

Protocol-level rewards that were distributed by this bank

§cluster_type: Option<ClusterType>§transaction_log_collector_config: Arc<RwLock<TransactionLogCollectorConfig>>§transaction_log_collector: Arc<RwLock<TransactionLogCollector>>§feature_set: Arc<FeatureSet>§drop_callback: RwLock<OptionalDropCallback>

callback function only to be called when dropping and should only be called once

§freeze_started: AtomicBool§block_component_processor: RwLock<BlockComponentProcessor>

Block component processor for validating block headers/footers and clock bounds. We currently write to this during replay, as we process block components one at a time, and read from this once replay is complete.

Implementations§

Source§

impl Bank

Source

pub fn enqueue_on_chain_accounts_lt_hash_updates<'a>( &self, accounts: &impl StorableAccounts<'a>, )

Enqueues the accounts lt hash updates for accounts to the accounts hasher thread pool.

This fn is meant to be called by on-chain events, e.g. transaction processing. This fn deduplicates from accounts, keeping only the latest version of each account. It also loads the previous version of each account inline, because we assume the previous version of each account is still in the accounts write cache, and thus fast to load.

For non-transaction processing callers, consider enqueue_off_chain_accounts_lt_hash_updates().

Source

pub fn enqueue_off_chain_accounts_lt_hash_updates<'a>( &self, accounts: &impl StorableAccounts<'a>, thread_pool_for_loading_accounts: Option<&ThreadPool>, )

Enqueues the accounts lt hash updates for accounts to the accounts hasher thread pool.

This fn is meant to be called by off-chain events, meaning we know/control accounts. Contrasting with enqueue_on_chain_accounts_lt_hash_updates(), this fn:

  • Does not deduplicate accounts, requiring the caller to ensure there are no duplicates.
  • Does not assume loading the previous version of accounts is fast, e.g. when storing stake accounts as part of partitioned epoch rewards.

If Some, thread_pool_for_hashing_accounts will be used to load the previous version of accounts in parallel.

Source

pub fn finish_accounts_lt_hash_updates(&self)

Updates the accounts lt hash.

When freezing a bank, we compute and update the accounts lt hash. For each account modified in this bank, we:

  • mix out its previous state, and
  • mix in its current state

This function waits for any in-flight jobs on the accounts hasher threads, computes their combined delta lt hash, then mixes it into the bank.

Source§

impl Bank

Source

pub fn load_addresses_from_ref<'a>( &self, address_table_lookups: impl Iterator<Item = SVMMessageAddressTableLookup<'a>>, ) -> Result<(LoadedAddresses, Slot), AddressLoaderError>

Load addresses from an iterator of SVMMessageAddressTableLookup, additionally returning the minimum deactivation slot across all referenced ALTs

Source§

impl Bank

Source

pub fn check_transactions_with_forwarding_delay( &self, transactions: &[impl TransactionWithMeta], filter: &[TransactionResult<()>], forward_transactions_to_leader_at_slot_offset: u64, ) -> Vec<TransactionCheckResult>

Checks a batch of sanitized transactions again bank for age and status

Source

pub fn check_transactions<Tx: TransactionWithMeta>( &self, sanitized_txs: &[impl Borrow<Tx>], lock_results: &[TransactionResult<()>], max_age: usize, strict_nonce_size_check: bool, error_counters: &mut TransactionErrorMetrics, ) -> Vec<TransactionCheckResult>

Source

pub fn check_transactions_without_status_cache<Tx: TransactionWithMeta>( &self, sanitized_txs: &[impl Borrow<Tx>], lock_results: &[TransactionResult<()>], max_age: usize, strict_nonce_size_check: bool, error_counters: &mut TransactionErrorMetrics, ) -> Vec<TransactionCheckResult>

Checks a batch of sanitized transactions against the bank for age and compute-budget limits, without checking the status cache.

Source

pub fn check_transactions_with_processed_slots<Tx: TransactionWithMeta>( &self, sanitized_txs: &[impl Borrow<Tx>], lock_results: &[TransactionResult<()>], max_age: usize, collect_processed_slots: bool, strict_nonce_size_check: bool, error_counters: &mut TransactionErrorMetrics, ) -> (Vec<TransactionCheckResult>, Option<Vec<Option<Slot>>>)

Source§

impl Bank

Source

pub fn calculate_reward_for_transaction( &self, transaction: &impl TransactionWithMeta, transaction_configuration: &TransactionConfiguration, ) -> u64

Source

pub fn calculate_reward_and_burn_fee_details( &self, fee_details: &CollectorFeeDetails, ) -> FeeDistribution

Source§

impl Bank

Source§

impl Bank

Source

pub fn new_from_genesis( genesis_config: &GenesisConfig, runtime_config: Arc<RuntimeConfig>, paths: Vec<PathBuf>, debug_keys: Option<Arc<HashSet<Pubkey>>>, accounts_db_config: AccountsDbConfig, accounts_update_notifier: Option<AccountsUpdateNotifier>, leader_for_tests: Option<SlotLeader>, exit: Arc<AtomicBool>, genesis_hash: Option<Hash>, feature_set: Option<FeatureSet>, ) -> Self

Source

pub fn new_from_parent( parent: Arc<Bank>, leader: SlotLeader, slot: Slot, ) -> Self

Create a new bank that points to an immutable checkpoint of another bank.

Source

pub fn new_from_parent_with_options( parent: Arc<Bank>, leader: SlotLeader, slot: Slot, new_bank_options: NewBankOptions, ) -> Self

Source

pub fn new_from_parent_with_tracer( parent: Arc<Bank>, leader: SlotLeader, slot: Slot, reward_calc_tracer: impl RewardCalcTracer, ) -> Self

Source

pub fn set_fork_graph_in_program_cache( &self, fork_graph: Weak<RwLock<BankForks>>, )

Source

pub fn prune_program_cache(&self, bank_forks: &BankForks)

Source

pub fn prune_program_cache_by_deployment_slot(&self, deployment_slot: Slot)

Source

pub fn new_warmup_cooldown_rate_epoch(&self) -> Option<Epoch>

Epoch in which the new cooldown warmup rate for stake was activated

Source

pub fn proper_ancestors_set(&self) -> HashSet<Slot>

Source

pub fn set_callback( &self, callback: Option<Box<dyn DropCallback + Send + Sync>>, )

Source

pub fn vote_only_bank(&self) -> bool

Source

pub fn warp_from_parent( parent: Arc<Bank>, leader: SlotLeader, slot: Slot, ) -> Self

Like new_from_parent but additionally:

  • Doesn’t assume that the parent is anywhere near slot, parent could be millions of slots in the past
  • Adjusts the new bank’s tick height to avoid having to run PoH for millions of slots
  • Freezes the new bank, assuming that the user will Bank::new_from_parent from this bank
Source

pub fn leader(&self) -> &SlotLeader

Source

pub fn leader_id(&self) -> &Pubkey

Source

pub fn genesis_creation_time(&self) -> UnixTimestamp

Source

pub fn slot(&self) -> Slot

Source

pub fn bank_id(&self) -> BankId

Source

pub fn epoch(&self) -> Epoch

Source

pub fn first_normal_epoch(&self) -> Epoch

Source

pub fn freeze_lock(&self) -> RwLockReadGuard<'_, Hash>

Source

pub fn wait_for_inflight_commits(&self)

Waits for in-flight BankingStage commits to finish without freezing the bank.

BankingStage holds the read side of this lock from before a successful PoH record until after the matching account commit. Taking and dropping the write side gives callers a quiescence point before abandoning and purging an unfrozen leader bank.

Source

pub fn hash(&self) -> Hash

Source

pub fn is_frozen(&self) -> bool

Source

pub fn freeze_started(&self) -> bool

Source

pub fn status_cache_ancestors(&self) -> Vec<u64>

Source

pub fn unix_timestamp_from_genesis(&self) -> i64

computed unix_timestamp at this slot height

Source

pub fn epoch_stakes_from_slot( &self, slot: Slot, ) -> Option<&VersionedEpochStakes>

Returns a reference to the VersionedEpochStakes corresponding to the given Slot.

Source

pub fn get_rank_map(&self, slot: Slot) -> Option<&Arc<BLSPubkeyToRankMap>>

Returns a reference to BLSPubkeyToRankMap for the given slot.

Source

pub fn clock(&self) -> Clock

Source

pub fn update_last_restart_slot(&self)

Source

pub fn set_sysvar_for_tests<T>(&self, sysvar: &T)

Source

pub fn get_slot_history(&self) -> Option<SlotHistory>

Source

pub fn set_epoch_stakes_for_test( &mut self, epoch: Epoch, stakes: VersionedEpochStakes, )

Source

pub fn get_vat_health_for_next_epoch( &self, vote_account_pubkey: &Pubkey, ) -> Result<(), VATHealthError>

Source

pub fn ns_per_slot_at_slot(&self, slot: Slot) -> u128

Returns the effective slot duration for slot.

Source

pub fn slot_range_duration_nanos( &self, start_slot: Slot, end_slot: Slot, ) -> u128

Returns the exact wall-clock duration in nanoseconds for start_slot..=end_slot.

Source

pub fn epoch_duration_in_years(&self, epoch: Epoch) -> f64

Source

pub fn max_processing_age(&self) -> usize

Source

pub fn slot_in_year_for_inflation(&self) -> f64

Returns elapsed inflation time in years for slots since inflation started.

Source

pub fn update_recent_blockhashes(&self)

Source

pub fn rehash(&self)

Recalculates the bank hash

This is used by ledger-tool when creating a snapshot, which recalculates the bank hash.

Note that the account state is not allowed to change by rehashing. If modifying accounts in ledger-tool is needed, create a new bank.

Source

pub fn freeze(&self)

Source

pub fn freeze_and_verify_bank_hash(&self) -> Result<(), (Hash, Hash)>

Freeze the bank and verify its computed bank hash against the expected bank hash, If hashes do not match, return Err with (expected_hash, computed_hash)

Source

pub fn set_expected_bank_hash(&self, hash: Hash)

Set the expected bank hash (from an external footer). This is stored for later verification when the bank is frozen.

Source

pub fn expected_bank_hash(&self) -> Option<Hash>

Returns the expected bank hash if any.

Source

pub fn unfreeze_for_ledger_tool(&self)

Source

pub fn epoch_schedule(&self) -> &EpochSchedule

Source

pub fn squash(&self) -> SquashTiming

squash the parent’s state up into this Bank, this Bank becomes a root Note that this function is not thread-safe. If it is called concurrently on the same bank by multiple threads, the end result could be inconsistent. Calling code does not currently call this concurrently.

Source

pub fn parent(&self) -> Option<Arc<Bank>>

Return the more recent checkpoint of this bank instance.

Source

pub fn parent_slot(&self) -> Slot

Source

pub fn parent_hash(&self) -> Hash

Source

pub fn add_precompiled_account(&self, program_id: &Pubkey)

Add a precompiled program account

Source

pub fn set_rent_burn_percentage(&mut self, burn_percent: u8)

Source

pub fn set_hashes_per_tick(&self, hashes_per_tick: Option<u64>)

Source

pub fn last_blockhash(&self) -> Hash

Return the last block hash registered.

Source

pub fn last_blockhash_and_lamports_per_signature(&self) -> (Hash, u64)

Source

pub fn is_blockhash_valid(&self, hash: &Hash) -> bool

Source

pub fn get_minimum_balance_for_rent_exemption(&self, data_len: usize) -> u64

Source

pub fn get_lamports_per_signature(&self) -> u64

Source

pub fn get_lamports_per_signature_for_blockhash( &self, hash: &Hash, ) -> Option<u64>

Source

pub fn get_fee_for_message(&self, message: &SanitizedMessage) -> Option<u64>

Source

pub fn get_blockhash_last_valid_block_height( &self, blockhash: &Hash, ) -> Option<Slot>

Source

pub fn get_alpenglow_genesis_certificate(&self) -> Option<Certificate>

Query the alpenglow genesis certificate account. All frozen alpenglow banks will have this account populated and TowerBFT banks will not.

The same is true for alpenglow banks yet to be frozen except for the first alpenglow bank:

  • The first alpenglow bank will contain a special marker that populates this account
  • If get_alpenglow_genesis_certificate is called before the marker is processed by replay this account will be empty.
  • If get_alpenglow_genesis_certificate is called after the marker is processed, we return the certificate
Source

pub fn is_alpenglow(&self) -> bool

Source

pub fn set_alpenglow_genesis_certificate(&self, cert: &Certificate)

For use in the first Alpenglow block, set the genesis certificate.

Update the clock sysvar from a block footer’s nanosecond timestamp. Also stores the nanosecond value for later retrieval via get_nanosecond_clock.

Source

pub fn get_nanosecond_clock(&self) -> Option<i64>

Get the nanosecond clock value. Returns None if the nanosecond clock has not been populated (i.e., before Alpenglow migration completes).

Source

pub fn confirmed_last_blockhash(&self) -> Hash

Source

pub fn clear_signatures(&self)

Forget all signatures. Useful for benchmarking.

Source

pub fn clear_slot_signatures(&self, slot: Slot)

Source

pub fn register_unique_recent_blockhash_for_test(&self)

Source

pub fn register_recent_blockhash_for_test( &self, blockhash: &Hash, lamports_per_signature: Option<u64>, )

Source

pub fn register_tick(&self, hash: &Hash, scheduler: &InstalledSchedulerRwLock)

Tell the bank which Entry IDs exist on the ledger. This function assumes subsequent calls correspond to later entries, and will boot the oldest ones once its internal cache is full. Once boot, the bank will reject transactions using that hash.

This is NOT thread safe because if tick height is updated by two different threads, the block boundary condition could be missed.

Source

pub fn register_tick_for_test(&self, hash: &Hash)

Source

pub fn register_default_tick_for_test(&self)

Source

pub fn is_complete(&self) -> bool

Source

pub fn is_block_boundary(&self, tick_height: u64) -> bool

Source

pub fn get_transaction_account_lock_limit(&self) -> usize

Get the max number of accounts that a transaction may lock in this block

Source

pub fn prepare_entry_batch( &self, txs: Vec<VersionedTransaction>, ) -> Result<TransactionBatch<'_, '_, RuntimeTransaction<SanitizedTransaction>>>

Prepare a transaction batch from a list of versioned transactions from an entry. Used for tests only.

Source

pub fn try_lock_accounts( &self, txs: &[impl TransactionWithMeta], ) -> Vec<Result<()>>

Attempt to take locks on the accounts in a transaction batch

Source

pub fn try_lock_accounts_with_results( &self, txs: &[impl TransactionWithMeta], tx_results: impl Iterator<Item = Result<()>>, ) -> Vec<Result<()>>

Attempt to take locks on the accounts in a transaction batch, and their cost limited packing status and duplicate transaction conflict status

Source

pub fn prepare_sanitized_batch<'a, 'b, Tx: TransactionWithMeta>( &'a self, txs: &'b [Tx], ) -> TransactionBatch<'a, 'b, Tx>

Prepare a locked transaction batch from a list of sanitized transactions.

Source

pub fn prepare_sanitized_batch_with_results<'a, 'b, Tx: TransactionWithMeta>( &'a self, transactions: &'b [Tx], transaction_results: impl Iterator<Item = Result<()>>, ) -> TransactionBatch<'a, 'b, Tx>

Prepare a locked transaction batch from a list of sanitized transactions, and their cost limited packing status

Source

pub fn prepare_unlocked_batch_from_single_tx<'a, Tx: SVMMessage>( &'a self, transaction: &'a Tx, ) -> TransactionBatch<'a, 'a, Tx>

Prepare a transaction batch from a single transaction without locking accounts

Source

pub fn prepare_locked_batch_from_single_tx<'a, Tx: TransactionWithMeta>( &'a self, transaction: &'a Tx, ) -> TransactionBatch<'a, 'a, Tx>

Prepare a transaction batch from a single transaction after locking accounts

Source

pub fn resanitize_transaction_minimally( &self, transaction: &impl TransactionWithMeta, sanitized_epoch: Epoch, alt_invalidation_slot: Slot, ) -> Result<()>

Source

pub fn simulate_transaction( &self, transaction: &impl TransactionWithMeta, enable_cpi_recording: bool, ) -> TransactionSimulationResult

Run transactions against a frozen bank without committing the results

Source

pub fn simulate_transaction_unchecked( &self, transaction: &impl TransactionWithMeta, enable_cpi_recording: bool, ) -> TransactionSimulationResult

Run transactions against a bank without committing the results; does not check if the bank is frozen, enabling use in single-Bank test frameworks

Source

pub fn unlock_accounts<'a, Tx: SVMMessage + 'a>( &self, txs_and_results: impl Iterator<Item = (&'a Tx, &'a Result<()>)> + Clone, )

Source

pub fn remove_unrooted_slots(&self, slots: &[(Slot, BankId)])

Source

pub fn get_hash_age(&self, hash: &Hash) -> Option<u64>

Source

pub fn is_hash_valid_for_age(&self, hash: &Hash, max_age: usize) -> bool

Source

pub fn collect_balances( &self, batch: &TransactionBatch<'_, '_, impl SVMMessage>, ) -> TransactionBalances

Source

pub fn load_and_execute_transactions( &self, batch: &TransactionBatch<'_, '_, impl TransactionWithMeta>, max_age: usize, timings: &mut ExecuteTimings, error_counters: &mut TransactionErrorMetrics, processing_config: TransactionProcessingConfig<'_>, ) -> LoadAndExecuteTransactionsOutput

Source

pub fn load_accounts_data_size(&self) -> u64

Load the accounts data size, in bytes

Source

pub fn load_accounts_data_size_delta(&self) -> i64

Load the change in accounts data size in this Bank, in bytes

Source

pub fn load_accounts_data_size_delta_on_chain(&self) -> i64

Load the change in accounts data size in this Bank, in bytes, from on-chain events i.e. transactions

Source

pub fn load_accounts_data_size_delta_off_chain(&self) -> i64

Load the change in accounts data size in this Bank, in bytes, from off-chain events i.e. rent collection

Source

pub fn commit_transactions( &self, sanitized_txs: &[impl TransactionWithMeta], processing_results: Vec<TransactionProcessingResult>, processed_counts: &ProcessedTransactionCounts, timings: &mut ExecuteTimings, ) -> Vec<TransactionCommitResult>

Source

pub fn cluster_type(&self) -> ClusterType

Source

pub fn load_execute_and_commit_transactions( &self, batch: &TransactionBatch<'_, '_, impl TransactionWithMeta>, recording_config: ExecutionRecordingConfig, timings: &mut ExecuteTimings, log_messages_bytes_limit: Option<usize>, ) -> (Vec<TransactionCommitResult>, Option<BalanceCollector>)

Process a batch of transactions.

Source

pub fn load_execute_and_commit_transactions_with_pre_commit_callback<'a>( &'a self, batch: &TransactionBatch<'_, '_, impl TransactionWithMeta>, recording_config: ExecutionRecordingConfig, timings: &mut ExecuteTimings, log_messages_bytes_limit: Option<usize>, pre_commit_callback: impl FnOnce(&mut ExecuteTimings, &[TransactionProcessingResult]) -> PreCommitResult<'a>, ) -> Result<(Vec<TransactionCommitResult>, Option<BalanceCollector>)>

Source

pub fn process_transaction(&self, tx: &Transaction) -> Result<()>

Process a Transaction. This is used for unit tests and simply calls the vector Bank::process_transactions method.

Source

pub fn process_transaction_with_metadata( &self, tx: impl Into<VersionedTransaction>, ) -> Result<CommittedTransaction>

Process a Transaction and store metadata. This is used for tests and the banks services. It replicates the vector Bank::process_transaction method with metadata recording enabled.

Source

pub fn try_process_transactions<'a>( &self, txs: impl Iterator<Item = &'a Transaction>, ) -> Result<Vec<Result<()>>>

Process multiple transaction in a single batch. This is used for benches and unit tests. Short circuits if any of the transactions do not pass sanitization checks.

Source

pub fn try_process_entry_transactions( &self, txs: Vec<VersionedTransaction>, ) -> Result<Vec<Result<()>>>

Process multiple transaction in a single batch. This is used for benches and unit tests. Short circuits if any of the transactions do not pass sanitization checks.

Source

pub fn transfer( &self, n: u64, keypair: &Keypair, to: &Pubkey, ) -> Result<Signature>

Create, sign, and process a Transaction from keypair to to of n lamports where blockhash is the last Entry ID observed by the client.

Source

pub fn read_balance(account: &AccountSharedData) -> u64

Source

pub fn get_balance(&self, pubkey: &Pubkey) -> u64

Each program would need to be able to introspect its own state this is hard-coded to the Budget language

Source

pub fn parents(&self) -> Vec<Arc<Bank>>

Compute all the parents of the bank in order

Source

pub fn parents_inclusive(self: Arc<Self>) -> Vec<Arc<Bank>>

Compute all the parents of the bank including this bank itself

Source

pub fn store_account(&self, pubkey: &Pubkey, account: &AccountSharedData)

fn store the single account with pubkey. Uses store_accounts, which works on a vector of accounts.

Source

pub fn store_accounts<'a>( &self, accounts: impl StorableAccounts<'a>, thread_pool_for_loading_accounts: Option<&ThreadPool>, )

Source

pub fn force_flush_accounts_cache(&self)

Source

pub fn accounts(&self) -> Arc<Accounts>

Source

pub fn set_tick_height(&self, tick_height: u64)

Source

pub fn set_inflation(&self, inflation: Inflation)

Source

pub fn hard_forks(&self) -> HardForks

Get a snapshot of the current set of hard forks

Source

pub fn register_hard_fork(&self, new_hard_fork_slot: Slot)

Source

pub fn register_hard_forks(&self, new_hard_fork_slots: Option<&Vec<Slot>>)

Source

pub fn get_account_with_fixed_root_no_cache( &self, pubkey: &Pubkey, ) -> Option<AccountSharedData>

Source

pub fn get_account(&self, pubkey: &Pubkey) -> Option<AccountSharedData>

Source

pub fn get_account_with_fixed_root( &self, pubkey: &Pubkey, ) -> Option<AccountSharedData>

Source

pub fn get_account_modified_slot_with_fixed_root( &self, pubkey: &Pubkey, ) -> Option<(AccountSharedData, Slot)>

Source

pub fn get_account_modified_slot( &self, pubkey: &Pubkey, ) -> Option<(AccountSharedData, Slot)>

Source

pub fn get_program_accounts( &self, program_id: &Pubkey, ) -> ScanResult<Vec<KeyedAccountSharedData>>

Source

pub fn get_filtered_program_accounts<F: Fn(&AccountSharedData) -> bool>( &self, program_id: &Pubkey, filter: F, ) -> ScanResult<Vec<KeyedAccountSharedData>>

Source

pub fn get_filtered_indexed_accounts<F: Fn(&AccountSharedData) -> bool>( &self, index_key: &IndexKey, filter: F, byte_limit_for_scan: Option<usize>, ) -> ScanResult<Vec<KeyedAccountSharedData>>

Source

pub fn account_indexes_include_key(&self, key: &Pubkey) -> bool

Source

pub fn scan_all_accounts<F>(&self, scan_func: F) -> ScanResult<()>

Source

pub fn get_program_accounts_modified_since_parent( &self, program_id: &Pubkey, ) -> Vec<KeyedAccountSharedData>

Source

pub fn get_transaction_logs( &self, address: Option<&Pubkey>, ) -> Option<Vec<TransactionLogInfo>>

Source

pub fn get_all_accounts_modified_since_parent( &self, ) -> Vec<KeyedAccountSharedData>

Returns all the accounts stored in this slot

Source

pub fn get_largest_accounts( &self, num: usize, filter_by_address: &HashSet<Pubkey>, filter: AccountAddressFilter, ) -> ScanResult<Vec<(Pubkey, u64)>>

Source

pub fn transaction_count(&self) -> u64

Return the accumulated executed transaction count

Source

pub fn non_vote_transaction_count_since_restart(&self) -> u64

Returns the number of non-vote transactions processed without error since the most recent boot from snapshot or genesis. This value is not shared though the network, nor retained within snapshots, but is preserved in Bank::new_from_parent.

Source

pub fn executed_transaction_count(&self) -> u64

Return the transaction count executed only in this bank

Source

pub fn transaction_error_count(&self) -> u64

Source

pub fn transaction_entries_count(&self) -> u64

Source

pub fn transactions_per_entry_max(&self) -> u64

Source

pub fn max_data_shreds_per_slot(&self) -> u32

Source

pub fn max_code_shreds_per_slot(&self) -> u32

Source

pub fn max_data_shreds_per_slot_for_slot(&self, slot: Slot) -> u32

Returns the data shred limit applicable to slot.

Limit changes are delayed by an epoch, so a root bank can derive the limit for any slot inside the shred intake window.

Source

pub fn max_code_shreds_per_slot_for_slot(&self, slot: Slot) -> u32

Returns the code shred limit applicable to slot.

Limit changes are delayed by an epoch, so a root bank can derive the limit for any slot inside the shred intake window.

Source

pub fn max_entry_bytes_per_slot(&self) -> u64

Source

pub fn entry_bytes_budget(&self) -> &EntryBytesBudget

Source

pub fn signature_count(&self) -> u64

Source

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

Source

pub fn get_signature_status_with_blockhash( &self, signature: &Signature, blockhash: &Hash, ) -> Option<Result<()>>

Source

pub fn get_committed_transaction_status_and_slot( &self, message_hash: &Hash, transaction_blockhash: &Hash, ) -> Option<(Slot, bool)>

Source

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

Source

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

Source

pub fn has_signature(&self, signature: &Signature) -> bool

Source

pub fn run_final_hash_calc(&self)

Used by ledger tool to run a final hash calculation once all ledger replay has completed. This should not be called by validator code.

Source

pub fn get_snapshot_storages( &self, base_slot: Option<Slot>, ) -> Vec<Arc<AccountStorageEntry>>

Get this bank’s storages to use for snapshots.

If a base slot is provided, return only the storages that are higher than this slot.

Source

pub fn verify_transaction( &self, tx: VersionedTransaction, verification_mode: TransactionVerificationMode, ) -> Result<RuntimeTransaction<SanitizedTransaction>>

Verify the transaction signatures, hash and other metadata.

Source

pub fn verify_transaction_with_serialized_message( &self, tx: VersionedTransaction, serialized_message: &[u8], verification_mode: TransactionVerificationMode, ) -> Result<RuntimeTransaction<SanitizedTransaction>>

Verify the transaction signatures, hash and other metadata, using the provided serialized message.

Verifying a transaction requires the serialized message to calculate the message hash. Use this function if the message is already available. Note that the serialized message MUST correspond to the transaction’s message.

Source

pub fn check_reserved_keys(&self, tx: &impl SVMMessage) -> Result<()>

Checks if the transaction violates the bank’s reserved keys. This needs to be checked upon epoch boundary crosses because the reserved key set may have changed since the initial sanitization.

Source

pub fn calculate_capitalization_for_tests(&self) -> u64

Calculates and returns the capitalization.

Panics if capitalization overflows a u64.

Note, this is very expensive! It walks the whole accounts index, account-by-account, summing each account’s balance.

Only intended to be called at startup by ledger-tool or tests. (cannot be made DCOU due to solana-program-test)

Source

pub fn set_capitalization_for_tests(&self, capitalization: u64)

Sets the capitalization.

Only intended to be called by ledger-tool or tests. (cannot be made DCOU due to solana-program-test)

Source

pub fn get_snapshot_hash(&self) -> SnapshotHash

Returns the SnapshotHash for this bank’s slot

This fn is used at startup to verify the bank was rebuilt correctly.

Source

pub fn verify_snapshot_bank( &self, skip_shrink: bool, force_clean: bool, latest_full_snapshot_slot: Slot, calculated_accounts_lt_hash: Option<&AccountsLtHash>, ) -> bool

A snapshot bank should be purged of 0 lamport accounts which are not part of the hash calculation and could shield other real accounts.

Source

pub fn hashes_per_tick(&self) -> Option<u64>

Return the number of hashes per tick

Source

pub fn ticks_per_slot(&self) -> u64

Return the number of ticks per slot

Source

pub fn ticks_per_second(&self) -> u64

Return the target number of ticks per second for this bank.

Source

pub fn slots_per_year(&self) -> f64

Return the number of slots per year

Source

pub fn tick_height(&self) -> u64

Return the number of ticks since genesis.

Source

pub fn inflation(&self) -> Inflation

Return the inflation parameters of the Bank

Source

pub fn rent_collector(&self) -> &RentCollector

Return the rent collector for this Bank

Source

pub fn capitalization(&self) -> u64

Return the total capitalization of the Bank

Source

pub fn max_tick_height(&self) -> u64

Return this bank’s max_tick_height

Source

pub fn block_height(&self) -> u64

Return the block_height of this bank

Source

pub fn get_slots_in_epoch(&self, epoch: Epoch) -> u64

Return the number of slots per epoch for the given epoch

Source

pub fn get_leader_schedule_epoch(&self, slot: Slot) -> Epoch

returns the epoch for which this bank’s leader_schedule_slot_offset and slot would need to cache leader_schedule

Source

pub fn vote_accounts(&self) -> Arc<VoteAccountsHashMap>

current vote accounts for this bank along with the stake attributed to each account

Source

pub fn get_vote_account(&self, vote_account: &Pubkey) -> Option<VoteAccount>

Vote account for the given vote account pubkey.

Source

pub fn current_epoch_stakes(&self) -> &VersionedEpochStakes

Get the EpochStakes for the current Bank::epoch

Source

pub fn epoch_stakes(&self, epoch: Epoch) -> Option<&VersionedEpochStakes>

Get the EpochStakes for a given epoch

Source

pub fn verify_certificate( &self, cert: UnverifiedCertificate, ) -> Result<Certificate, CertVerifyError>

Verify a BLS certificate’s signature using this bank’s epoch stakes.

Source

pub fn epoch_stakes_map(&self) -> &HashMap<Epoch, VersionedEpochStakes>

Source

pub fn current_epoch_staked_nodes(&self) -> Arc<HashMap<Pubkey, u64>>

Returns a mapping from validator Pubkey to stake in Lamports for the current Bank::epoch.

Source

pub fn epoch_staked_nodes( &self, epoch: Epoch, ) -> Option<Arc<HashMap<Pubkey, u64>>>

Returns a mapping from validator Pubkey to stake in Lamports for the given epoch.

Source

pub fn epoch_total_stake(&self, epoch: Epoch) -> Option<u64>

Returns the total stake in Lamports for the given epoch.

Source

pub fn get_current_epoch_total_stake(&self) -> u64

Returns the total stake in Lamports for the current Bank::epoch.

Source

pub fn epoch_vote_accounts(&self, epoch: Epoch) -> Option<&VoteAccountsHashMap>

Returns a mapping from Pubkey to (stake in Lamports and VoteAccount) for the given epoch.

Source

pub fn get_current_epoch_vote_accounts(&self) -> &VoteAccountsHashMap

Returns a mapping from Pubkey to (stake in Lamports and VoteAccount) for the current Bank::epoch.

Source

pub fn epoch_authorized_voter(&self, vote_account: &Pubkey) -> Option<&Pubkey>

Get the fixed authorized voter for the given vote account for the current epoch

Source

pub fn epoch_vote_accounts_for_node_id( &self, node_id: &Pubkey, ) -> Option<&NodeVoteAccounts>

Get the fixed set of vote accounts for the given node id for the current epoch

Source

pub fn epoch_node_id_to_stake( &self, epoch: Epoch, node_id: &Pubkey, ) -> Option<u64>

Returns the total stake in Lamports belonging to vote accounts associated with the given node_id for the given epoch.

Source

pub fn total_epoch_stake(&self) -> u64

Returns the total stake in Lamports of all vote accounts for current Bank::epoch.

Source

pub fn epoch_vote_account_stake(&self, vote_account: &Pubkey) -> u64

Get the fixed stake of the given vote account for the current epoch

Source

pub fn get_epoch_and_slot_index(&self, slot: Slot) -> (Epoch, SlotIndex)

given a slot, return the epoch and offset into the epoch this slot falls e.g. with a fixed number for slots_per_epoch, the calculation is simply:

( slot/slots_per_epoch, slot % slots_per_epoch )

Source

pub fn get_epoch_info(&self) -> EpochInfo

Source

pub fn is_empty(&self) -> bool

Source

pub fn add_mockup_builtin( &mut self, program_id: Pubkey, builtin: BuiltinFunctionRegisterer, )

Source

pub fn add_precompile(&mut self, program_id: &Pubkey)

Source

pub fn print_accounts_stats(&self)

Source

pub fn shrink_candidate_slots(&self) -> usize

Source

pub fn read_cost_tracker(&self) -> LockResult<RwLockReadGuard<'_, CostTracker>>

Source

pub fn write_cost_tracker( &self, ) -> LockResult<RwLockWriteGuard<'_, CostTracker>>

Source

pub fn should_bank_still_be_processing_txs( bank_creation_time: &Instant, max_tx_ingestion_nanos: u128, ) -> bool

Source

pub fn deactivate_feature(&mut self, id: &Pubkey)

Source

pub fn activate_feature(&mut self, id: &Pubkey)

Source

pub fn fill_bank_with_ticks_for_tests(&self)

Source

pub fn get_reserved_account_keys(&self) -> &HashSet<Pubkey>

Get a set of all actively reserved account keys that are not allowed to be write-locked during transaction processing.

Source

pub fn compute_pending_activation_slot( &self, feature_id: &Pubkey, ) -> Option<Slot>

If feature_id is pending to be activated at the next epoch boundary, return the first slot at which it will be active (the epoch boundary).

Source

pub fn calculate_accounts_data_size(&self) -> ScanResult<u64>

Calculates the accounts data size of all accounts

Panics if total overflows a u64.

Note, this may be very expensive, as all accounts are accessed.

Only intended to be called by tests or when the number of accounts is small.

Source

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

Source

pub fn check_program_deployment_slot(&self) -> bool

Source

pub fn set_check_program_deployment_slot(&mut self, check: bool)

Source

pub fn fee_structure(&self) -> &FeeStructure

Source

pub fn parent_block_id(&self) -> Option<Hash>

Source

pub fn block_id(&self) -> Option<Hash>

Source

pub fn set_block_id(&self, block_id: Option<Hash>)

Source

pub fn compute_budget(&self) -> Option<ComputeBudget>

Source

pub fn add_builtin( &self, program_id: Pubkey, name: &str, builtin: ProgramCacheEntry, )

Source

pub fn get_bank_hash_stats(&self) -> BankHashStats

Source

pub fn clear_epoch_rewards_cache(&self)

Source

pub fn set_accounts_lt_hash_for_snapshot_minimizer( &self, accounts_lt_hash: AccountsLtHash, )

Sets the accounts lt hash, only to be used by SnapshotMinimizer

Source

pub fn get_collector_fee_details(&self) -> CollectorFeeDetails

Return total transaction fee collected

Source

pub fn minimum_vote_account_balance_for_vat(&self) -> u64

Minimum balance a vote account must hold to survive SIMD-0357 filtering under the current feature set. When alpenglow is active the threshold also includes one epoch’s worth of VAT burn.

Source

pub fn get_top_epoch_stakes(&self) -> Stakes<StakeAccount<Delegation>>

If the VAT feature is active, returns the Stakes as filtered by SIMD-0357 See VoteAccounts::clone_and_filter_for_vat for the full criteria

If the VAT feature is not active, return all stakes

Source

pub fn calculate_and_set_block_id_for_dcou(bank: &Bank)

Calculates and sets block id for bank.

This fn operates recursively. Since calculating the block id requires the bank’s parent’s block id, if the bank’s parent’s block id is unset, it will be calculated and set first.

Note this fn will also freeze bank.

Only to be called from dev contexts. Couldn’t make the fn actually DCOU, since it is called by Validator::new() when warping a slot.

Source§

impl Bank

Source

pub fn new_for_txn_tests( bank_rc: BankRc, fields: BankFieldsToDeserialize, feature_set: FeatureSet, epoch_stakes: HashMap<Epoch, VersionedEpochStakes>, ) -> Self

Create a bank for transaction testing. Constructs the bank struct, applies activated features, and fills missing sysvar cache entries. Skips block-level setup (prepare_for_block_execution, partitioned rewards recalc) and snapshot fields (stakes loading, debug keys, accounts data size) that are irrelevant to individual transaction execution.

Important: The returned bank must be inserted into a BankForks before calling load_and_execute_transactions, because the program cache requires a ForkGraph to be present.

Source

pub fn new_for_block_tests( bank_rc: BankRc, fields: BankFieldsToDeserialize, feature_set: FeatureSet, epoch_stakes: HashMap<Epoch, VersionedEpochStakes>, stakes: Stakes<StakeAccount<Delegation>>, accounts_data_size_initial: u64, ) -> Self

Create a bank for block testing. Constructs the bank struct, applies activated features, recalculates partitioned rewards if mid-distribution, and runs prepare_for_block_execution to complete the _new_from_parent-equivalent initialization (epoch processing, sysvar updates, LT hash cache).

Important: The returned bank must be inserted into a BankForks before calling load_and_execute_transactions, because the program cache requires a ForkGraph to be present.

Source

pub fn wrap_with_bank_forks_for_tests( self, ) -> (Arc<Self>, Arc<RwLock<BankForks>>)

Source

pub fn default_for_tests() -> Self

Source

pub fn new_with_bank_forks_for_tests( genesis_config: &GenesisConfig, ) -> (Arc<Self>, Arc<RwLock<BankForks>>)

Source

pub fn new_for_tests(genesis_config: &GenesisConfig) -> Self

Source

pub fn new_with_mockup_builtin_for_tests( genesis_config: &GenesisConfig, program_id: Pubkey, builtin: BuiltinFunctionRegisterer, ) -> (Arc<Self>, Arc<RwLock<BankForks>>)

Source

pub fn new_with_paths_for_tests( genesis_config: &GenesisConfig, test_config: Option<BankTestConfig>, paths: Vec<PathBuf>, leader: Option<SlotLeader>, ) -> Self

Source

pub fn new_for_benches(genesis_config: &GenesisConfig) -> Self

Source

pub fn new_with_paths_for_benches( genesis_config: &GenesisConfig, paths: Vec<PathBuf>, ) -> Self

Intended for use by benches only. create new bank with the given config and paths.

Source

pub fn new_from_parent_with_bank_forks( bank_forks: &RwLock<BankForks>, parent: Arc<Bank>, leader: SlotLeader, slot: Slot, ) -> Arc<Self>

Source

pub fn prepare_batch_for_tests( &self, txs: Vec<Transaction>, ) -> TransactionBatch<'_, '_, RuntimeTransaction<SanitizedTransaction>>

Prepare a transaction batch from a list of legacy transactions. Used for tests only.

Source

pub fn set_accounts_data_size_initial_for_tests(&mut self, amount: u64)

Set the initial accounts data size NOTE: This fn is ONLY FOR TESTS

Source

pub fn update_accounts_data_size_delta_off_chain_for_tests(&self, amount: i64)

Update the accounts data size off-chain delta NOTE: This fn is ONLY FOR TESTS

Source

pub fn process_transactions<'a>( &self, txs: impl Iterator<Item = &'a Transaction>, ) -> Vec<Result<()>>

Process multiple transaction in a single batch. This is used for benches and unit tests.

§Panics

Panics if any of the transactions do not pass sanitization checks.

Source

pub fn process_entry_transactions( &self, txs: Vec<VersionedTransaction>, ) -> Vec<Result<()>>

Process entry transactions in a single batch. This is used for benches and unit tests.

§Panics

Panics if any of the transactions do not pass sanitization checks.

Source

pub fn get_sysvar_cache_for_tests(&self) -> SysvarCache

Source

pub fn calculate_accounts_lt_hash_for_tests(&self) -> AccountsLtHash

Source

pub fn get_transaction_processor(&self) -> &TransactionBatchProcessor<BankForks>

Source

pub fn set_fee_structure(&mut self, fee_structure: &FeeStructure)

Source

pub fn load_program( &self, pubkey: &Pubkey, effective_epoch: Epoch, ) -> Option<Arc<ProgramCacheEntry>>

Source

pub fn withdraw(&self, pubkey: &Pubkey, lamports: u64) -> Result<()>

Source

pub fn set_hash_overrides(&self, hash_overrides: HashOverrides)

Source

pub fn slot_time_reduction_active(&self) -> bool

Returns true when this bank is using slot params beyond its genesis baseline.

Trait Implementations§

Source§

impl AddressLoader for &Bank

Source§

impl Debug for Bank

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for Bank

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl InvokeContextCallback for Bank

Source§

fn get_epoch_stake(&self) -> u64

Returns the total current epoch stake for the network.
Source§

fn get_epoch_stake_for_vote_account(&self, vote_address: &Pubkey) -> u64

Returns the current epoch stake for the given vote account.
Source§

fn is_precompile(&self, program_id: &Pubkey) -> bool

Returns true if the program_id corresponds to a precompiled program
Source§

fn process_precompile( &self, program_id: &Pubkey, data: &[u8], instruction_datas: Vec<&[u8]>, ) -> Result<(), PrecompileError>

Calls the precompiled program corresponding to the given program ID.
Source§

impl PartialEq for Bank

Available on crate feature dev-context-only-utils only.
Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl TransactionProcessingCallback for Bank

Source§

fn get_account_shared_data( &self, pubkey: &Pubkey, ) -> Option<(AccountSharedData, Slot)>

Source§

fn inspect_account( &self, _address: &Pubkey, _account_state: AccountState<'_>, _is_writable: bool, )

Auto Trait Implementations§

§

impl !Freeze for Bank

§

impl !RefUnwindSafe for Bank

§

impl !UnwindSafe for Bank

§

impl Send for Bank

§

impl Sync for Bank

§

impl Unpin for Bank

§

impl UnsafeUnpin for Bank

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> Any for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Source§

fn type_name(&self) -> &'static str

Source§

impl<T> AnySync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

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> Conv for T

Source§

fn conv<T>(self) -> T
where Self: Into<T>,

Converts self into T using Into<T>. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> FmtForward for T

Source§

fn fmt_binary(self) -> FmtBinary<Self>
where Self: Binary,

Causes self to use its Binary implementation when Debug-formatted.
Source§

fn fmt_display(self) -> FmtDisplay<Self>
where Self: Display,

Causes self to use its Display implementation when Debug-formatted.
Source§

fn fmt_lower_exp(self) -> FmtLowerExp<Self>
where Self: LowerExp,

Causes self to use its LowerExp implementation when Debug-formatted.
Source§

fn fmt_lower_hex(self) -> FmtLowerHex<Self>
where Self: LowerHex,

Causes self to use its LowerHex implementation when Debug-formatted.
Source§

fn fmt_octal(self) -> FmtOctal<Self>
where Self: Octal,

Causes self to use its Octal implementation when Debug-formatted.
Source§

fn fmt_pointer(self) -> FmtPointer<Self>
where Self: Pointer,

Causes self to use its Pointer implementation when Debug-formatted.
Source§

fn fmt_upper_exp(self) -> FmtUpperExp<Self>
where Self: UpperExp,

Causes self to use its UpperExp implementation when Debug-formatted.
Source§

fn fmt_upper_hex(self) -> FmtUpperHex<Self>
where Self: UpperHex,

Causes self to use its UpperHex implementation when Debug-formatted.
Source§

fn fmt_list(self) -> FmtList<Self>
where &'a Self: for<'a> IntoIterator,

Formats each item in a sequence. 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> MaybeSendSync for T

Source§

impl<D> OwoColorize for D

Source§

fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>
where C: Color,

Set the foreground color generically Read more
Source§

fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>
where C: Color,

Set the background color generically. Read more
Source§

fn black<'a>(&'a self) -> FgColorDisplay<'a, Black, Self>

Change the foreground color to black
Source§

fn on_black<'a>(&'a self) -> BgColorDisplay<'a, Black, Self>

Change the background color to black
Source§

fn red<'a>(&'a self) -> FgColorDisplay<'a, Red, Self>

Change the foreground color to red
Source§

fn on_red<'a>(&'a self) -> BgColorDisplay<'a, Red, Self>

Change the background color to red
Source§

fn green<'a>(&'a self) -> FgColorDisplay<'a, Green, Self>

Change the foreground color to green
Source§

fn on_green<'a>(&'a self) -> BgColorDisplay<'a, Green, Self>

Change the background color to green
Source§

fn yellow<'a>(&'a self) -> FgColorDisplay<'a, Yellow, Self>

Change the foreground color to yellow
Source§

fn on_yellow<'a>(&'a self) -> BgColorDisplay<'a, Yellow, Self>

Change the background color to yellow
Source§

fn blue<'a>(&'a self) -> FgColorDisplay<'a, Blue, Self>

Change the foreground color to blue
Source§

fn on_blue<'a>(&'a self) -> BgColorDisplay<'a, Blue, Self>

Change the background color to blue
Source§

fn magenta<'a>(&'a self) -> FgColorDisplay<'a, Magenta, Self>

Change the foreground color to magenta
Source§

fn on_magenta<'a>(&'a self) -> BgColorDisplay<'a, Magenta, Self>

Change the background color to magenta
Source§

fn purple<'a>(&'a self) -> FgColorDisplay<'a, Magenta, Self>

Change the foreground color to purple
Source§

fn on_purple<'a>(&'a self) -> BgColorDisplay<'a, Magenta, Self>

Change the background color to purple
Source§

fn cyan<'a>(&'a self) -> FgColorDisplay<'a, Cyan, Self>

Change the foreground color to cyan
Source§

fn on_cyan<'a>(&'a self) -> BgColorDisplay<'a, Cyan, Self>

Change the background color to cyan
Source§

fn white<'a>(&'a self) -> FgColorDisplay<'a, White, Self>

Change the foreground color to white
Source§

fn on_white<'a>(&'a self) -> BgColorDisplay<'a, White, Self>

Change the background color to white
Source§

fn default_color<'a>(&'a self) -> FgColorDisplay<'a, Default, Self>

Change the foreground color to the terminal default
Source§

fn on_default_color<'a>(&'a self) -> BgColorDisplay<'a, Default, Self>

Change the background color to the terminal default
Source§

fn bright_black<'a>(&'a self) -> FgColorDisplay<'a, BrightBlack, Self>

Change the foreground color to bright black
Source§

fn on_bright_black<'a>(&'a self) -> BgColorDisplay<'a, BrightBlack, Self>

Change the background color to bright black
Source§

fn bright_red<'a>(&'a self) -> FgColorDisplay<'a, BrightRed, Self>

Change the foreground color to bright red
Source§

fn on_bright_red<'a>(&'a self) -> BgColorDisplay<'a, BrightRed, Self>

Change the background color to bright red
Source§

fn bright_green<'a>(&'a self) -> FgColorDisplay<'a, BrightGreen, Self>

Change the foreground color to bright green
Source§

fn on_bright_green<'a>(&'a self) -> BgColorDisplay<'a, BrightGreen, Self>

Change the background color to bright green
Source§

fn bright_yellow<'a>(&'a self) -> FgColorDisplay<'a, BrightYellow, Self>

Change the foreground color to bright yellow
Source§

fn on_bright_yellow<'a>(&'a self) -> BgColorDisplay<'a, BrightYellow, Self>

Change the background color to bright yellow
Source§

fn bright_blue<'a>(&'a self) -> FgColorDisplay<'a, BrightBlue, Self>

Change the foreground color to bright blue
Source§

fn on_bright_blue<'a>(&'a self) -> BgColorDisplay<'a, BrightBlue, Self>

Change the background color to bright blue
Source§

fn bright_magenta<'a>(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>

Change the foreground color to bright magenta
Source§

fn on_bright_magenta<'a>(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>

Change the background color to bright magenta
Source§

fn bright_purple<'a>(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>

Change the foreground color to bright purple
Source§

fn on_bright_purple<'a>(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>

Change the background color to bright purple
Source§

fn bright_cyan<'a>(&'a self) -> FgColorDisplay<'a, BrightCyan, Self>

Change the foreground color to bright cyan
Source§

fn on_bright_cyan<'a>(&'a self) -> BgColorDisplay<'a, BrightCyan, Self>

Change the background color to bright cyan
Source§

fn bright_white<'a>(&'a self) -> FgColorDisplay<'a, BrightWhite, Self>

Change the foreground color to bright white
Source§

fn on_bright_white<'a>(&'a self) -> BgColorDisplay<'a, BrightWhite, Self>

Change the background color to bright white
Source§

fn bold<'a>(&'a self) -> BoldDisplay<'a, Self>

Make the text bold
Source§

fn dimmed<'a>(&'a self) -> DimDisplay<'a, Self>

Make the text dim
Source§

fn italic<'a>(&'a self) -> ItalicDisplay<'a, Self>

Make the text italicized
Source§

fn underline<'a>(&'a self) -> UnderlineDisplay<'a, Self>

Make the text italicized
Make the text blink
Make the text blink (but fast!)
Source§

fn reversed<'a>(&'a self) -> ReversedDisplay<'a, Self>

Swap the foreground and background colors
Source§

fn hidden<'a>(&'a self) -> HiddenDisplay<'a, Self>

Hide the text
Source§

fn strikethrough<'a>(&'a self) -> StrikeThroughDisplay<'a, Self>

Cross out the text
Source§

fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>
where Color: DynColor,

Set the foreground color at runtime. Only use if you do not know which color will be used at compile-time. If the color is constant, use either OwoColorize::fg or a color-specific method, such as OwoColorize::green, Read more
Source§

fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>
where Color: DynColor,

Set the background color at runtime. Only use if you do not know what color to use at compile-time. If the color is constant, use either OwoColorize::bg or a color-specific method, such as OwoColorize::on_yellow, Read more
Source§

fn fg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>

Set the foreground color to a specific RGB value.
Source§

fn bg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>

Set the background color to a specific RGB value.
Source§

fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>

Sets the foreground color to an RGB value.
Source§

fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>

Sets the background color to an RGB value.
Source§

fn style(&self, style: Style) -> Styled<&Self>

Apply a runtime-determined style
Source§

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

Source§

fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
where Self: Sized,

Pipes by value. This is generally the method you want to use. Read more
Source§

fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R
where R: 'a,

Borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R
where R: 'a,

Mutably borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
where Self: Borrow<B>, B: 'a + ?Sized, R: 'a,

Borrows self, then passes self.borrow() into the pipe function. Read more
Source§

fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
where Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
Source§

fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
where Self: AsRef<U>, U: 'a + ?Sized, R: 'a,

Borrows self, then passes self.as_ref() into the pipe function.
Source§

fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
where Self: AsMut<U>, U: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.as_mut() into the pipe function.
Source§

fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
where Self: Deref<Target = T>, T: 'a + ?Sized, R: 'a,

Borrows self, then passes self.deref() into the pipe function.
Source§

fn pipe_deref_mut<'a, T, R>( &'a mut self, func: impl FnOnce(&'a mut T) -> R, ) -> R
where Self: DerefMut<Target = T> + Deref, T: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.deref_mut() into the pipe function.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Tap for T

Source§

fn tap(self, func: impl FnOnce(&Self)) -> Self

Immutable access to a value. Read more
Source§

fn tap_mut(self, func: impl FnOnce(&mut Self)) -> Self

Mutable access to a value. Read more
Source§

fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Immutable access to the Borrow<B> of a value. Read more
Source§

fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Mutable access to the BorrowMut<B> of a value. Read more
Source§

fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Immutable access to the AsRef<R> view of a value. Read more
Source§

fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Mutable access to the AsMut<R> view of a value. Read more
Source§

fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Immutable access to the Deref::Target of a value. Read more
Source§

fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Mutable access to the Deref::Target of a value. Read more
Source§

fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self

Calls .tap() only in debug builds, and is erased in release builds.
Source§

fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self

Calls .tap_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Calls .tap_borrow() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Calls .tap_borrow_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Calls .tap_ref() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Calls .tap_ref_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Calls .tap_deref() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_mut_dbg<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Calls .tap_deref_mut() only in debug builds, and is erased in release builds.
Source§

impl<T> TryConv for T

Source§

fn try_conv<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Attempts to convert self into T using TryInto<T>. Read more
Source§

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

Source§

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>,

Source§

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<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