1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
use {
    super::Bank,
    solana_address_lookup_table_program::error::AddressLookupError,
    solana_sdk::{
        message::v0::{LoadedAddresses, MessageAddressTableLookup},
        transaction::{AddressLoader, Result as TransactionResult, TransactionError},
    },
};

impl AddressLoader for &Bank {
    fn load_addresses(
        self,
        address_table_lookups: &[MessageAddressTableLookup],
    ) -> TransactionResult<LoadedAddresses> {
        if !self.versioned_tx_message_enabled() {
            return Err(TransactionError::UnsupportedVersion);
        }

        let slot_hashes = self
            .sysvar_cache
            .read()
            .unwrap()
            .get_slot_hashes()
            .map_err(|_| TransactionError::AccountNotFound)?;

        Ok(address_table_lookups
            .iter()
            .map(|address_table_lookup| {
                self.rc.accounts.load_lookup_table_addresses(
                    &self.ancestors,
                    address_table_lookup,
                    &slot_hashes,
                )
            })
            .collect::<Result<_, AddressLookupError>>()?)
    }
}