From 9328ee4f6390cff803a08e695b5b17b031da729c Mon Sep 17 00:00:00 2001 From: Greg Fitzgerald Date: Fri, 11 Jan 2019 14:06:30 -0700 Subject: [PATCH] Revert "Revert "Delete unused code and its tests"" This reverts commit d6b3991d4916dec03e0f684105d345d76ecba3a2. --- src/bank.rs | 10 ---------- src/status_deque.rs | 35 ----------------------------------- 2 files changed, 45 deletions(-) diff --git a/src/bank.rs b/src/bank.rs index 00bac93d4..5c8e4df8f 100644 --- a/src/bank.rs +++ b/src/bank.rs @@ -305,16 +305,6 @@ impl Bank { } } - /// Look through the last_ids and find all the valid ids - /// This is batched to avoid holding the lock for a significant amount of time - /// - /// Return a vec of tuple of (valid index, timestamp) - /// index is into the passed ids slice to avoid copying hashes - pub fn count_valid_ids(&self, ids: &[Hash]) -> Vec<(usize, u64)> { - let last_ids = self.last_ids.read().unwrap(); - last_ids.count_valid_ids(ids) - } - /// Looks through a list of tick heights and stakes, and finds the latest /// tick that has achieved confirmation pub fn get_confirmation_timestamp( diff --git a/src/status_deque.rs b/src/status_deque.rs index 952cf87ba..8d975ad91 100644 --- a/src/status_deque.rs +++ b/src/status_deque.rs @@ -214,22 +214,6 @@ impl StatusDeque { None } - /// Look through the last_ids and find all the valid ids - /// This is batched to avoid holding the lock for a significant amount of time - /// - /// Return a vec of tuple of (valid index, timestamp) - /// index is into the passed ids slice to avoid copying hashes - pub fn count_valid_ids(&self, ids: &[Hash]) -> Vec<(usize, u64)> { - let mut ret = Vec::new(); - for (i, id) in ids.iter().enumerate() { - if let Some(entry) = self.entries.get(id) { - if self.tick_height - entry.tick_height < MAX_ENTRY_IDS as u64 { - ret.push((i, entry.timestamp)); - } - } - } - ret - } pub fn get_signature_status(&self, signature: &Signature) -> Option> { for entry in self.entries.values() { if let Some(res) = entry.statuses.get(signature) { @@ -286,25 +270,6 @@ mod tests { ); } - #[test] - fn test_count_valid_ids() { - let first_id = Default::default(); - let mut status_deque: StatusDeque<()> = StatusDeque::default(); - status_deque.register_tick(&first_id); - let ids: Vec<_> = (0..MAX_ENTRY_IDS) - .map(|i| { - let last_id = hash(&serialize(&i).unwrap()); // Unique hash - status_deque.register_tick(&last_id); - last_id - }) - .collect(); - assert_eq!(status_deque.count_valid_ids(&[]).len(), 0); - assert_eq!(status_deque.count_valid_ids(&[first_id]).len(), 0); - for (i, id) in status_deque.count_valid_ids(&ids).iter().enumerate() { - assert_eq!(id.0, i); - } - } - #[test] fn test_clear_signatures() { let signature = Signature::default();