pub struct Bank {
Show 14 fields pub rc: BankRc, pub src: StatusCacheRc, pub ancestors: Ancestors, pub ns_per_slot: u128, 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, pub fee_structure: FeeStructure, /* private fields */
}
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: StatusCacheRcancestors: 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>lazy_rent_collection: AtomicBoolrewards_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: AtomicBoolfee_structure: FeeStructure

Transaction fee structure

Implementations

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

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

squash the parent’s state up into this Bank, this Bank becomes a root

Return the more recent checkpoint of this bank instance.

Add a builtin program account

Add a precompiled program account

Return the last block hash registered.

👎 Deprecated since 1.9.0:

Please use get_fee_for_message instead

👎 Deprecated since 1.6.11:

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.

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

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

source

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

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

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

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

Run transactions against a frozen bank without committing the results

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

Calculate fee for SanitizedMessage

committed_transactions_count is the number of transactions out of sanitized_txs that was executed. Of those, committed_transactions_count, committed_with_failure_result_count is the number of executed transactions that returned a failure result.

used only by filler accounts in debug path previous means slot - 1, not parent

Process a batch of transactions.

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

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.

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 process_entry_transactions(
    &self,
    txs: Vec<VersionedTransaction>
) -> Vec<Result<()>>Notable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
    A: Allocator

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

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

Compute all the parents of the bank including this bank itself

source

pub fn transactions_per_entry_max(&self) -> u64

Recalculate the hash_internal_state from the account stores. Would be used to verify a snapshot. Only called from startup or test code.

Forcibly overwrites current capitalization by actually recalculating accounts’ balances. This should only be used for developing purposes.

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 inflation parameters of the Bank

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 vote accounts for this bank along with the stake attributed to each account

Vote account for the given vote account pubkey along with the stake.

Get the EpochStakes for a given epoch

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 )

Add an instruction processor to intercept instructions before the dynamic loader.

Remove a builtin instruction processor if it already exists

Get all the accounts for this bank and calculate stats

Given all the accounts for a bank, calculate stats

Trait Implementations

Formats the value using the given formatter. Read more

Executes the destructor for this type. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

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

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

Calls U::from(self).

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

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

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

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

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