AcctIdx: simplify AccountIndexGetResult (#21857)
This commit is contained in:
committed by
GitHub
parent
17cd14ad88
commit
98e5ea9dce
@ -3332,10 +3332,7 @@ impl AccountsDb {
|
|||||||
let (lock, index) = match self.accounts_index.get(pubkey, Some(ancestors), max_root) {
|
let (lock, index) = match self.accounts_index.get(pubkey, Some(ancestors), max_root) {
|
||||||
AccountIndexGetResult::Found(lock, index) => (lock, index),
|
AccountIndexGetResult::Found(lock, index) => (lock, index),
|
||||||
// we bail out pretty early for missing.
|
// we bail out pretty early for missing.
|
||||||
AccountIndexGetResult::NotFoundOnFork => {
|
AccountIndexGetResult::NotFound => {
|
||||||
return None;
|
|
||||||
}
|
|
||||||
AccountIndexGetResult::Missing(_) => {
|
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -248,10 +248,9 @@ impl<T: IndexValue> AccountMapEntryInner<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum AccountIndexGetResult<'a, T: IndexValue> {
|
pub enum AccountIndexGetResult<T: IndexValue> {
|
||||||
Found(ReadAccountMapEntry<T>, usize),
|
Found(ReadAccountMapEntry<T>, usize),
|
||||||
NotFoundOnFork,
|
NotFound,
|
||||||
Missing(AccountMapsReadLock<'a, T>),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[self_referencing]
|
#[self_referencing]
|
||||||
@ -1523,7 +1522,7 @@ impl<T: IndexValue> AccountsIndex<T> {
|
|||||||
pubkey: &Pubkey,
|
pubkey: &Pubkey,
|
||||||
ancestors: Option<&Ancestors>,
|
ancestors: Option<&Ancestors>,
|
||||||
max_root: Option<Slot>,
|
max_root: Option<Slot>,
|
||||||
) -> AccountIndexGetResult<'_, T> {
|
) -> AccountIndexGetResult<T> {
|
||||||
let read_lock = self.account_maps[self.bin_calculator.bin_from_pubkey(pubkey)]
|
let read_lock = self.account_maps[self.bin_calculator.bin_from_pubkey(pubkey)]
|
||||||
.read()
|
.read()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
@ -1538,10 +1537,10 @@ impl<T: IndexValue> AccountsIndex<T> {
|
|||||||
let found_index = self.latest_slot(ancestors, slot_list, max_root);
|
let found_index = self.latest_slot(ancestors, slot_list, max_root);
|
||||||
match found_index {
|
match found_index {
|
||||||
Some(found_index) => AccountIndexGetResult::Found(locked_entry, 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<T: IndexValue> AccountIndexGetResult<T> {
|
||||||
pub fn unwrap(self) -> (ReadAccountMapEntry<T>, usize) {
|
pub fn unwrap(self) -> (ReadAccountMapEntry<T>, usize) {
|
||||||
match self {
|
match self {
|
||||||
AccountIndexGetResult::Found(lock, size) => (lock, size),
|
AccountIndexGetResult::Found(lock, size) => (lock, size),
|
||||||
|
Reference in New Issue
Block a user