Skip to content

Commit

Permalink
rebased
Browse files Browse the repository at this point in the history
  • Loading branch information
aeyakovenko committed Mar 1, 2019
1 parent 152e3a1 commit fd0e764
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 23 deletions.
21 changes: 6 additions & 15 deletions src/bank_forks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,28 +27,19 @@ impl BankForks {
working_bank,
}
}
pub fn frozen_banks(&self) -> Vec<u64> {
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<u64, Arc<Bank>> {
let mut frozen_banks: Vec<Arc<Bank>> = 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<u64> {
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<Bank>> {
self.banks.get(&bank_id)
Expand Down
7 changes: 5 additions & 2 deletions src/fullnode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
16 changes: 10 additions & 6 deletions src/replay_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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<u64> = 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 {
Expand Down

0 comments on commit fd0e764

Please sign in to comment.