From 98e5ea9dcea7b1dbc748362b10edcdbe9d12602e Mon Sep 17 00:00:00 2001 From: "Jeff Washington (jwash)" Date: Mon, 13 Dec 2021 21:16:17 -0600 Subject: [PATCH] AcctIdx: simplify AccountIndexGetResult (#21857) --- runtime/src/accounts_db.rs | 5 +---- runtime/src/accounts_index.rs | 13 ++++++------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/runtime/src/accounts_db.rs b/runtime/src/accounts_db.rs index 8aa75369c8..3940e60eb4 100644 --- a/runtime/src/accounts_db.rs +++ b/runtime/src/accounts_db.rs @@ -3332,10 +3332,7 @@ impl AccountsDb { let (lock, index) = match self.accounts_index.get(pubkey, Some(ancestors), max_root) { AccountIndexGetResult::Found(lock, index) => (lock, index), // we bail out pretty early for missing. - AccountIndexGetResult::NotFoundOnFork => { - return None; - } - AccountIndexGetResult::Missing(_) => { + AccountIndexGetResult::NotFound => { return None; } }; diff --git a/runtime/src/accounts_index.rs b/runtime/src/accounts_index.rs index 5f43c4e6a6..aa76d4242c 100644 --- a/runtime/src/accounts_index.rs +++ b/runtime/src/accounts_index.rs @@ -248,10 +248,9 @@ impl AccountMapEntryInner { } } -pub enum AccountIndexGetResult<'a, T: IndexValue> { +pub enum AccountIndexGetResult { Found(ReadAccountMapEntry, usize), - NotFoundOnFork, - Missing(AccountMapsReadLock<'a, T>), + NotFound, } #[self_referencing] @@ -1523,7 +1522,7 @@ impl AccountsIndex { pubkey: &Pubkey, ancestors: Option<&Ancestors>, max_root: Option, - ) -> AccountIndexGetResult<'_, T> { + ) -> AccountIndexGetResult { let read_lock = self.account_maps[self.bin_calculator.bin_from_pubkey(pubkey)] .read() .unwrap(); @@ -1538,10 +1537,10 @@ impl AccountsIndex { let found_index = self.latest_slot(ancestors, slot_list, max_root); match found_index { Some(found_index) => AccountIndexGetResult::Found(locked_entry, found_index), - None => AccountIndexGetResult::NotFoundOnFork, + None => AccountIndexGetResult::NotFound, } } - None => AccountIndexGetResult::Missing(read_lock), + None => AccountIndexGetResult::NotFound, } } @@ -2029,7 +2028,7 @@ pub mod tests { } } - impl<'a, T: IndexValue> AccountIndexGetResult<'a, T> { + impl AccountIndexGetResult { pub fn unwrap(self) -> (ReadAccountMapEntry, usize) { match self { AccountIndexGetResult::Found(lock, size) => (lock, size),