Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
76 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
use solana_sdk::{account::AccountSharedData, pubkey::Pubkey, sysvar}; | ||
|
||
/// Encapsulates overridden accounts, typically used for transaction simulations | ||
#[derive(Default)] | ||
pub struct AccountOverrides { | ||
pub slot_history: Option<AccountSharedData>, | ||
} | ||
|
||
impl AccountOverrides { | ||
/// 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; | ||
} | ||
|
||
/// Gets the account if it's found in the list of overrides | ||
pub fn get(&self, pubkey: &Pubkey) -> Option<&AccountSharedData> { | ||
if pubkey == &sysvar::slot_history::id() { | ||
self.slot_history.as_ref() | ||
} else { | ||
None | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters