Struct solana_runtime::bank::Bank [−][src]
pub struct Bank {Show 14 fields
pub rc: BankRc,
pub src: StatusCacheRc,
pub ancestors: Ancestors,
pub ns_per_slot: u128,
pub last_vote_sync: AtomicU64,
pub rewards: RwLock<Vec<(Pubkey, RewardInfo)>>,
pub cluster_type: Option<ClusterType>,
pub lazy_rent_collection: AtomicBool,
pub rewards_pool_pubkeys: Arc<HashSet<Pubkey>>,
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,
// some fields omitted
}
Expand description
Manager for the state of all accounts and programs after processing its entries. AbiExample is needed even without Serialize/Deserialize; actual (de-)serialization are implemented elsewhere for versioning
Fields
rc: BankRc
References to accounts, parent and signature status
src: StatusCacheRc
ancestors: Ancestors
The set of parents including this bank
ns_per_slot: u128
length of a slot in ns
last_vote_sync: AtomicU64
Last time when the cluster info vote listener has synced with this bank
rewards: RwLock<Vec<(Pubkey, RewardInfo)>>
Protocol-level rewards that were distributed by this bank
cluster_type: Option<ClusterType>
lazy_rent_collection: AtomicBool
rewards_pool_pubkeys: Arc<HashSet<Pubkey>>
transaction_log_collector_config: Arc<RwLock<TransactionLogCollectorConfig>>
transaction_log_collector: Arc<RwLock<TransactionLogCollector>>
feature_set: Arc<FeatureSet>
drop_callback: RwLock<OptionalDropCallback>
freeze_started: AtomicBool
Implementations
pub fn new_with_paths(
genesis_config: &GenesisConfig,
paths: Vec<PathBuf>,
frozen_account_pubkeys: &[Pubkey],
debug_keys: Option<Arc<HashSet<Pubkey>>>,
additional_builtins: Option<&Builtins>,
account_indexes: AccountSecondaryIndexes,
accounts_db_caching_enabled: bool,
shrink_ratio: AccountShrinkThreshold,
debug_do_not_add_builtins: bool
) -> Self
Create a new bank that points to an immutable checkpoint of another bank.
pub fn new_from_parent_with_options(
parent: &Arc<Bank>,
collector_id: &Pubkey,
slot: Slot,
new_bank_options: NewBankOptions
) -> Self
pub fn new_from_parent_with_tracer(
parent: &Arc<Bank>,
collector_id: &Pubkey,
slot: Slot,
reward_calc_tracer: impl Fn(&RewardCalculationEvent<'_, '_>) + Send + Sync
) -> 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
computed unix_timestamp at this slot height
Unused conversion
Return the more recent checkpoint of this bank instance.
Return the last block hash registered.
Please use get_blockhash_last_valid_block_height
Forget all signatures. Useful for benchmarking.
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
.
pub fn prepare_batch<'a, 'b>(
&'a self,
txs: impl Iterator<Item = &'b Transaction>
) -> TransactionBatch<'a, 'b>
pub fn prepare_hashed_batch<'a, 'b>(
&'a self,
hashed_txs: &'b [HashedTransaction<'_>]
) -> TransactionBatch<'a, 'b>
pub fn simulate_transaction(
&self,
transaction: &Transaction
) -> (Result<()>, TransactionLogMessages, Vec<(Pubkey, AccountSharedData)>)
pub fn simulate_transaction(
&self,
transaction: &Transaction
) -> (Result<()>, TransactionLogMessages, Vec<(Pubkey, AccountSharedData)>)
Run transactions against a frozen bank without committing the results
pub fn check_transactions(
&self,
hashed_txs: &[HashedTransaction<'_>],
lock_results: &[Result<()>],
max_age: usize,
error_counters: &mut ErrorCounters
) -> Vec<TransactionCheckResult>
Remove an executor from the bank’s cache
pub fn load_and_execute_transactions(
&self,
batch: &TransactionBatch<'_, '_>,
max_age: usize,
enable_cpi_recording: bool,
enable_log_recording: bool,
timings: &mut ExecuteTimings
) -> (Vec<TransactionLoadResult>, Vec<TransactionExecutionResult>, Vec<Option<InnerInstructionsList>>, Vec<Option<TransactionLogMessages>>, Vec<usize>, u64, u64)
pub fn commit_transactions(
&self,
hashed_txs: &[HashedTransaction<'_>],
loaded_txs: &mut [TransactionLoadResult],
executed: &[TransactionExecutionResult],
tx_count: u64,
signature_count: u64,
timings: &mut ExecuteTimings
) -> TransactionResults
pub fn load_execute_and_commit_transactions(
&self,
batch: &TransactionBatch<'_, '_>,
max_age: usize,
collect_balances: bool,
enable_cpi_recording: bool,
enable_log_recording: bool,
timings: &mut ExecuteTimings
) -> (TransactionResults, TransactionBalancesSet, Vec<Option<InnerInstructionsList>>, Vec<Option<TransactionLogMessages>>)
pub fn load_execute_and_commit_transactions(
&self,
batch: &TransactionBatch<'_, '_>,
max_age: usize,
collect_balances: bool,
enable_cpi_recording: bool,
enable_log_recording: bool,
timings: &mut ExecuteTimings
) -> (TransactionResults, TransactionBalancesSet, Vec<Option<InnerInstructionsList>>, Vec<Option<TransactionLogMessages>>)
Process a batch of transactions.
Process a Transaction. This is used for unit tests and simply calls the vector Bank::process_transactions method
Create, sign, and process a Transaction from keypair
to to
of
n
lamports where blockhash
is the last Entry ID observed by the client.
Each program would need to be able to introspect its own state this is hard-coded to the Budget language
Compute all the parents of the bank including this bank itself
pub fn get_program_accounts(
&self,
program_id: &Pubkey
) -> ScanResult<Vec<(Pubkey, AccountSharedData)>>
pub fn get_filtered_program_accounts<F: Fn(&AccountSharedData) -> bool>(
&self,
program_id: &Pubkey,
filter: F
) -> ScanResult<Vec<(Pubkey, AccountSharedData)>>
pub fn get_filtered_indexed_accounts<F: Fn(&AccountSharedData) -> bool>(
&self,
index_key: &IndexKey,
filter: F
) -> ScanResult<Vec<(Pubkey, AccountSharedData)>>
pub fn get_all_accounts_with_modified_slots(
&self
) -> ScanResult<Vec<(Pubkey, AccountSharedData, Slot)>>
pub fn get_program_accounts_modified_since_parent(
&self,
program_id: &Pubkey
) -> Vec<(Pubkey, AccountSharedData)>
pub fn get_transaction_logs(
&self,
address: Option<&Pubkey>
) -> Option<Vec<TransactionLogInfo>>
pub fn get_largest_accounts(
&self,
num: usize,
filter_by_address: &HashSet<Pubkey>,
filter: AccountAddressFilter
) -> ScanResult<Vec<(Pubkey, u64)>>
pub fn get_signature_status_processed_since_parent(
&self,
signature: &Signature
) -> Option<Result<()>>
pub fn get_signature_status_with_blockhash(
&self,
signature: &Signature,
blockhash: &Hash
) -> Option<Result<()>>
Forcibly overwrites current capitalization by actually recalculating accounts’ balances. This should only be used for developing purposes.
pub fn update_accounts_hash_with_index_option(
&self,
use_index: bool,
debug_verify: bool,
slots_per_epoch: Option<Slot>
) -> Hash
pub fn verify_snapshot_bank(
&self,
test_hash_calculation: bool,
accounts_db_skip_shrink: bool
) -> bool
pub fn verify_snapshot_bank(
&self,
test_hash_calculation: bool,
accounts_db_skip_shrink: bool
) -> 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.
Return the number of hashes per tick
Return the number of ticks per slot
Return the number of slots per year
Return the number of ticks since genesis.
Return the total capitalization of the Bank
Return this bank’s max_tick_height
Return the block_height of this bank
Return the number of slots per epoch for the given epoch
returns the epoch for which this bank’s leader_schedule_slot_offset and slot would need to cache leader_schedule
current stake delegations for this bank
current vote accounts for this bank along with the stake attributed to each account Note: This clones the entire vote-accounts hashmap. For a single account lookup use get_vote_account instead.
Vote account for the given vote account pubkey along with the stake.
Get the EpochStakes for a given epoch
pub fn epoch_vote_accounts(
&self,
epoch: Epoch
) -> Option<&HashMap<Pubkey, (u64, ArcVoteAccount)>>
pub fn epoch_vote_accounts(
&self,
epoch: Epoch
) -> Option<&HashMap<Pubkey, (u64, ArcVoteAccount)>>
vote accounts for the specific epoch along with the stake attributed to each account
Get the fixed authorized voter for the given vote account for the current epoch
Get the fixed set of vote accounts for the given node id for the current epoch
Get the fixed total stake of all vote accounts for current epoch
Get the fixed stake of the given vote account for the current epoch
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 )
pub fn add_builtin(
&mut self,
name: &str,
program_id: Pubkey,
process_instruction_with_context: ProcessInstructionWithContext
)
pub fn add_builtin(
&mut self,
name: &str,
program_id: Pubkey,
process_instruction_with_context: ProcessInstructionWithContext
)
Add an instruction processor to intercept instructions before the dynamic loader.
pub fn replace_builtin(
&mut self,
name: &str,
program_id: Pubkey,
process_instruction_with_context: ProcessInstructionWithContext
)
pub fn replace_builtin(
&mut self,
name: &str,
program_id: Pubkey,
process_instruction_with_context: ProcessInstructionWithContext
)
Replace a builtin instruction processor if it already exists
pub fn process_stale_slot_with_budget(
&self,
consumed_budget: usize,
budget_recovery_delta: usize
) -> usize
pub fn should_bank_still_be_processing_txs(
bank_creation_time: &Instant,
max_tx_ingestion_nanos: u128
) -> bool
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Bank
impl !UnwindSafe for Bank
Blanket Implementations
Mutably borrows from an owned value. Read more
pub fn vzip(self) -> V
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more