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
use {
solana_sdk::{account::AccountSharedData, pubkey::Pubkey, sysvar},
std::collections::HashMap,
};
#[derive(Default)]
pub struct AccountOverrides {
accounts: HashMap<Pubkey, AccountSharedData>,
}
impl AccountOverrides {
pub fn set_account(&mut self, pubkey: &Pubkey, account: Option<AccountSharedData>) {
match account {
Some(account) => self.accounts.insert(*pubkey, account),
None => self.accounts.remove(pubkey),
};
}
pub fn set_slot_history(&mut self, slot_history: Option<AccountSharedData>) {
self.set_account(&sysvar::slot_history::id(), slot_history);
}
pub fn get(&self, pubkey: &Pubkey) -> Option<&AccountSharedData> {
self.accounts.get(pubkey)
}
}