diff --git a/src/bank_forks.rs b/src/bank_forks.rs index 0635f87c70bd5c..d9b9fbc9b71285 100644 --- a/src/bank_forks.rs +++ b/src/bank_forks.rs @@ -27,28 +27,19 @@ impl BankForks { working_bank, } } - pub fn frozen_banks(&self) -> Vec { - let mut frozen_banks = vec![]; - frozen_banks.extend( - self.banks - .values() - .filter(|v| v.is_frozen()) - .map(|bank| bank.slot()), - ); + pub fn frozen_banks(&self) -> HashMap> { + let mut frozen_banks: Vec> = vec![]; + frozen_banks.extend(self.banks.values().filter(|v| v.is_frozen()).cloned()); frozen_banks.extend( self.banks .iter() .flat_map(|(_, v)| v.parents()) - .filter(|v| v.is_frozen()) - .map(|bank| bank.slot()), + .filter(|v| v.is_frozen()), ); - frozen_banks + frozen_banks.into_iter().map(|b| (b.slot(), b)).collect() } pub fn active_banks(&self) -> Vec { - self.banks - .iter() - .map(|(k, _v)| *k) - .collect() + self.banks.iter().map(|(k, _v)| *k).collect() } pub fn get(&self, bank_id: u64) -> Option<&Arc> { self.banks.get(&bank_id) diff --git a/src/fullnode.rs b/src/fullnode.rs index 862582e8ee9682..b6191a384d22bd 100644 --- a/src/fullnode.rs +++ b/src/fullnode.rs @@ -329,13 +329,16 @@ impl Fullnode { trace!("{:?}: rotate at slot={}", self.id, rotation_info.slot); //TODO: this will be called by the TVU every time it votes //instead of here - info!("reset PoH... {} {}", rotation_info.tick_height, rotation_info.last_id); + info!( + "reset PoH... {} {}", + rotation_info.tick_height, rotation_info.last_id + ); self.poh_recorder .lock() .unwrap() .reset(rotation_info.tick_height, rotation_info.last_id); let slot = rotation_info.slot; - let transition = self.rotate(rotation_info); + self.rotate(rotation_info); debug!("role transition complete: {:?}", transition); if let Some(ref rotation_notifier) = rotation_notifier { rotation_notifier.send(slot).unwrap(); diff --git a/src/replay_stage.rs b/src/replay_stage.rs index 317b6447791444..316835781ff8a7 100644 --- a/src/replay_stage.rs +++ b/src/replay_stage.rs @@ -139,9 +139,7 @@ impl ReplayStage { } debug!( "to_leader_sender: me: {} next_slot: {} next_leader: {}", - my_id, - next_slot, - next_leader + my_id, next_slot, next_leader ); to_leader_sender .send(TvuRotationInfo { @@ -219,10 +217,16 @@ impl ReplayStage { fn generate_new_bank_forks(blocktree: &Blocktree, forks: &mut BankForks) { // Find the next slot that chains to the old slot let frozen_banks = forks.frozen_banks(); - trace!("generate new forks {:?}", frozen_banks); - let next_slots = blocktree.get_slots_since(&frozen_banks).expect("Db error"); + let frozen_bank_ids: Vec = frozen_banks.keys().cloned().collect(); + trace!("generate new forks {:?}", frozen_bank_ids); + let next_slots = blocktree + .get_slots_since(&frozen_bank_ids) + .expect("Db error"); for (parent_id, children) in next_slots { - let parent_bank = forks.get(parent_id).unwrap().clone(); + let parent_bank = frozen_banks + .get(&parent_id) + .expect("missing parent in bank forks") + .clone(); for child_id in children { let new_fork = forks.get(child_id).is_none(); if new_fork {