solana_svm/
transaction_processing_callback.rs

1use {
2    solana_account::AccountSharedData, solana_feature_set::FeatureSet,
3    solana_fee_structure::FeeDetails, solana_pubkey::Pubkey,
4    solana_svm_transaction::svm_message::SVMMessage,
5};
6
7/// Runtime callbacks for transaction processing.
8pub trait TransactionProcessingCallback {
9    fn account_matches_owners(&self, account: &Pubkey, owners: &[Pubkey]) -> Option<usize>;
10
11    fn get_account_shared_data(&self, pubkey: &Pubkey) -> Option<AccountSharedData>;
12
13    fn add_builtin_account(&self, _name: &str, _program_id: &Pubkey) {}
14
15    fn inspect_account(&self, _address: &Pubkey, _account_state: AccountState, _is_writable: bool) {
16    }
17
18    fn get_current_epoch_vote_account_stake(&self, _vote_address: &Pubkey) -> u64 {
19        0
20    }
21    fn calculate_fee(
22        &self,
23        _message: &impl SVMMessage,
24        _lamports_per_signature: u64,
25        _prioritization_fee: u64,
26        _feature_set: &FeatureSet,
27    ) -> FeeDetails {
28        FeeDetails::default()
29    }
30}
31
32/// The state the account is in initially, before transaction processing
33#[derive(Debug)]
34pub enum AccountState<'a> {
35    /// This account is dead, and will be created by this transaction
36    Dead,
37    /// This account is alive, and already existed prior to this transaction
38    Alive(&'a AccountSharedData),
39}