Skip to content

Commit

Permalink
fix account overrides
Browse files Browse the repository at this point in the history
  • Loading branch information
whistlinwilly committed Jul 8, 2022
1 parent cc15469 commit 3f921a3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
1 change: 0 additions & 1 deletion core/src/bundle_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,6 @@ impl BundleStage {
let mut account_overrides = AccountOverrides {
slot_history: None,
cached_accounts_with_rent: HashMap::with_capacity(20),
accounts: HashMap::with_capacity(20),
};

let mut execution_results = Vec::new();
Expand Down
6 changes: 3 additions & 3 deletions runtime/src/account_overrides.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use {
pub struct AccountOverrides {
pub slot_history: Option<AccountSharedData>,
pub cached_accounts_with_rent: HashMap<Pubkey, AccountSharedData>,
pub accounts: HashMap<Pubkey, AccountSharedData>,
}

pub enum AccountWithRentInfo {
Expand All @@ -19,15 +18,16 @@ pub enum AccountWithRentInfo {
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),
Some(account) => self.cached_accounts_with_rent.insert(*pubkey, account),
None => self.cached_accounts_with_rent.remove(pubkey),
};
}

/// Sets in the slot history
///
/// Note: no checks are performed on the correctness of the contained data
pub fn set_slot_history(&mut self, slot_history: Option<AccountSharedData>) {
self.slot_history = slot_history.clone();
self.set_account(&sysvar::slot_history::id(), slot_history);
}

Expand Down

0 comments on commit 3f921a3

Please sign in to comment.