From 70c050f06af8b6872e46efb5cec08e2a8a86f24f Mon Sep 17 00:00:00 2001 From: HaoranYi <219428+HaoranYi@users.noreply.github.com> Date: Thu, 13 Feb 2025 16:14:43 +0000 Subject: [PATCH] fix build after rebase --- accounts-db/src/accounts_index.rs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/accounts-db/src/accounts_index.rs b/accounts-db/src/accounts_index.rs index d6ad5efcc32e88..1dc1646e90b0f6 100644 --- a/accounts-db/src/accounts_index.rs +++ b/accounts-db/src/accounts_index.rs @@ -623,15 +623,11 @@ impl + Into> Iterator } _ => { // else load the new bin - Self::range( - &map, - (self.start_bound, self.end_bound), - self.collect_all_unsorted, - ) + Self::range(&map, (self.start_bound, self.end_bound), self.returns_items) } }; for (count, (pubkey, account_map_entry)) in range.iter().enumerate() { - if chunk.len() >= ITER_BATCH_SIZE && !self.collect_all_unsorted { + if chunk.len() >= ITER_BATCH_SIZE && self.returns_items.is_sorted() { range.drain(0..count); self.last_bin_range = Some((bin, range)); break 'outer; @@ -665,6 +661,12 @@ pub enum AccountsIndexIteratorReturnsItems { Sorted, } +impl AccountsIndexIteratorReturnsItems { + pub fn is_sorted(&self) -> bool { + *self == AccountsIndexIteratorReturnsItems::Sorted + } +} + pub trait ZeroLamport { fn is_zero_lamport(&self) -> bool; } @@ -3954,7 +3956,10 @@ pub mod tests { } // Create an iterator for the whole pubkey range. - let mut iter = index.iter(None::<&Range>, COLLECT_ALL_UNSORTED_FALSE); + let mut iter = index.iter( + None::<&Range>, + AccountsIndexIteratorReturnsItems::Sorted, + ); // First iter.next() should return the first batch of pubkeys (1000 // pubkeys) out of the 2000 pubkeys in the first bin. And the remaining // 1000 pubkeys from the first bin should be cached in