From bb829c0bcffd24a66dc60ec90acb60d296b3a89e Mon Sep 17 00:00:00 2001 From: Andrew Fitzgerald Date: Tue, 23 Jan 2024 09:32:35 -0800 Subject: [PATCH] remove unused functions (#34895) --- .../transaction_state_container.rs | 78 ------------------- 1 file changed, 78 deletions(-) diff --git a/core/src/banking_stage/transaction_scheduler/transaction_state_container.rs b/core/src/banking_stage/transaction_scheduler/transaction_state_container.rs index 7c95f84353..d7d79cb21b 100644 --- a/core/src/banking_stage/transaction_scheduler/transaction_state_container.rs +++ b/core/src/banking_stage/transaction_scheduler/transaction_state_container.rs @@ -63,33 +63,6 @@ impl TransactionStateContainer { self.priority_queue.pop_max() } - /// Get an iterator of the top `n` transaction ids in the priority queue. - /// This will remove the ids from the queue, but not drain the remainder - /// of the queue. - pub(crate) fn take_top_n( - &mut self, - n: usize, - ) -> impl Iterator + '_ { - (0..n).map_while(|_| self.pop()) - } - - /// Serialize entire priority queue. `hold` indicates whether the priority queue should - /// be drained or not. - /// If `hold` is true, these ids should not be removed from the map while processing. - pub(crate) fn priority_ordered_ids(&mut self, hold: bool) -> Vec { - let priority_queue = if hold { - self.priority_queue.clone() - } else { - let capacity = self.priority_queue.capacity(); - core::mem::replace( - &mut self.priority_queue, - MinMaxHeap::with_capacity(capacity), - ) - }; - - priority_queue.into_vec_desc() - } - /// Get mutable transaction state by id. pub(crate) fn get_mut_transaction_state( &mut self, @@ -274,57 +247,6 @@ mod tests { ); } - #[test] - fn test_take_top_n() { - let mut container = TransactionStateContainer::with_capacity(5); - push_to_container(&mut container, 5); - - let taken = container.take_top_n(3).collect::>(); - assert_eq!( - taken, - vec![ - TransactionPriorityId::new(4, TransactionId::new(4)), - TransactionPriorityId::new(3, TransactionId::new(3)), - TransactionPriorityId::new(2, TransactionId::new(2)), - ] - ); - // The remainder of the queue should not be empty - assert_eq!(container.priority_queue.len(), 2); - } - - #[test] - fn test_priority_ordered_ids() { - let mut container = TransactionStateContainer::with_capacity(5); - push_to_container(&mut container, 5); - - let ordered = container.priority_ordered_ids(false); - assert_eq!( - ordered, - vec![ - TransactionPriorityId::new(4, TransactionId::new(4)), - TransactionPriorityId::new(3, TransactionId::new(3)), - TransactionPriorityId::new(2, TransactionId::new(2)), - TransactionPriorityId::new(1, TransactionId::new(1)), - TransactionPriorityId::new(0, TransactionId::new(0)), - ] - ); - assert!(container.priority_queue.is_empty()); - - push_to_container(&mut container, 5); - let ordered = container.priority_ordered_ids(true); - assert_eq!( - ordered, - vec![ - TransactionPriorityId::new(4, TransactionId::new(4)), - TransactionPriorityId::new(3, TransactionId::new(3)), - TransactionPriorityId::new(2, TransactionId::new(2)), - TransactionPriorityId::new(1, TransactionId::new(1)), - TransactionPriorityId::new(0, TransactionId::new(0)), - ] - ); - assert_eq!(container.priority_queue.len(), 5); - } - #[test] fn test_get_mut_transaction_state() { let mut container = TransactionStateContainer::with_capacity(5);