Overview
The Harmonic Salsa runtime library provides the core functionality for transaction processing, account management, and blockchain state management. The primary component is theBank struct, which represents a single slot in the blockchain and manages all account state and transaction execution for that slot.
Bank
TheBank struct is the main entry point for interacting with blockchain state. It tracks client accounts and the progress of on-chain programs.
Key Concepts
- A single bank relates to a block produced by a single leader
- Each bank (except genesis) points back to a parent bank
- Banks can be in one of three states: open, frozen, or rooted
- The bank provides both high-level APIs (that sign transactions) and low-level APIs (for pre-signed transactions)
Core Methods
Transaction Processing
Process a single transaction. The transaction must be properly signed and verified before calling this method.Parameters:
tx: A reference to theTransactionto process
Result<()>: Ok on success, or aTransactionErroron failure
process_transactions
fn<'a>(&self, txs: &[TransactionWithMetadata], &TransactionProcessingConfig) -> Vec<Result<()>>
Process multiple transactions as a batch. This is more efficient than processing transactions individually.Parameters:
txs: Slice of transactions with metadata to processconfig: Transaction processing configuration
Vec<Result<()>>: Vector of results, one per transaction
Account Management
Retrieve an account by its public key.Parameters:
pubkey: The public key of the account to retrieve
Option<AccountSharedData>: The account data if found, None otherwise
Get the lamport balance of an account.Parameters:
pubkey: The public key of the account
u64: The account balance in lamports
Store or update an account in the bank.Parameters:
pubkey: The public key of the accountaccount: The account data to store
Bank State
Get the slot number for this bank.Returns:
Slot: The slot number (u64)
Get the epoch number for this bank.Returns:
Epoch: The epoch number (u64)
Get the block height for this bank.Returns:
u64: The block height
Check if the bank is frozen (no more transactions can be processed).Returns:
bool: True if frozen, false otherwise
Freeze the bank, preventing any further modifications. After freezing, rent is applied and sysvars are updated.
Signature Status
Get the status of a transaction by its signature.Parameters:
signature: The transaction signature
Option<Result<()>>: The transaction result if found, None if not found
BankForks
TheBankForks struct manages multiple banks in a tree structure, representing the fork graph of the blockchain.
Methods
Get the root bank (the most recently finalized bank).Returns:
Arc<Bank>: Reference-counted pointer to the root bank
Get a bank by its slot number.Parameters:
slot: The slot number
Option<Arc<Bank>>: The bank if found
Related Modules
bank_client: Client interface for interacting with a bankbank_utils: Utility functions for bank operationscommitment: Commitment level trackingrent_collector: Rent collection and calculationsnapshot_utils: Snapshot creation and restorationstakes: Stake account managementstatus_cache: Transaction status caching
Example Usage
See Also
- SVM API - Low-level transaction processing
- Accounts DB API - Account storage layer
- Ledger API - Blockchain data storage