Skip to content

Commit

Permalink
Replaces message.account_keys[index] by accounts[index].0 in ThisInvo…
Browse files Browse the repository at this point in the history
…keContext
  • Loading branch information
Lichtso committed Jul 1, 2021
1 parent 0d35872 commit e46ed5b
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions runtime/src/message_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,9 +363,9 @@ impl<'a> InvokeContext for ThisInvokeContext<'a> {
let keyed_accounts = keyed_accounts
.iter()
.map(|(is_signer, is_writable, search_key, account)| {
self.message
.account_keys
.iter()
// REFACTOR: account_deps unification
(0..self.message.account_keys.len())
.map(|index| &self.accounts[index].0)
.chain(self.account_deps.iter().map(|(key, _account)| key))
.position(|key| key == *search_key)
.map(|mut index| {
Expand All @@ -374,7 +374,8 @@ impl<'a> InvokeContext for ThisInvokeContext<'a> {
// before calling MessageProcessor::process_cross_program_instruction
// Ideally we would recycle the existing accounts here.
let key = if index < self.message.account_keys.len() {
&self.message.account_keys[index]
// REFACTOR: account_deps unification
&self.accounts[index].0
// &self.accounts[index] as &RefCell<AccountSharedData>,
} else {
index = index.saturating_sub(self.message.account_keys.len());
Expand Down Expand Up @@ -471,11 +472,11 @@ impl<'a> InvokeContext for ThisInvokeContext<'a> {
self.feature_set.is_active(feature_id)
}
fn get_account(&self, pubkey: &Pubkey) -> Option<Rc<RefCell<AccountSharedData>>> {
if let Some(index) =
(0..self.message.account_keys.len()).position(|index| self.accounts[index].0 == *pubkey)
{
// REFACTOR: account_deps unification
return Some(self.accounts[index].1.clone());
// REFACTOR: account_deps unification
for index in 0..self.message.account_keys.len() {
if self.accounts[index].0 == *pubkey {
return Some(self.accounts[index].1.clone());
}
}
self.account_deps.iter().find_map(|(key, account)| {
if key == pubkey {
Expand Down

0 comments on commit e46ed5b

Please sign in to comment.