diff --git a/core/src/bank_forks.rs b/core/src/bank_forks.rs index f4f54b7907..60d4e81217 100644 --- a/core/src/bank_forks.rs +++ b/core/src/bank_forks.rs @@ -12,16 +12,16 @@ pub struct BankForks { impl Index for BankForks { type Output = Arc; - fn index(&self, bank_id: u64) -> &Arc { - &self.banks[&bank_id] + fn index(&self, bank_slot: u64) -> &Arc { + &self.banks[&bank_slot] } } impl BankForks { - pub fn new(bank_id: u64, bank: Bank) -> Self { + pub fn new(bank_slot: u64, bank: Bank) -> Self { let mut banks = HashMap::new(); let working_bank = Arc::new(bank); - banks.insert(bank_id, working_bank.clone()); + banks.insert(bank_slot, working_bank.clone()); Self { banks, working_bank, @@ -45,8 +45,8 @@ impl BankForks { .map(|(k, _v)| *k) .collect() } - pub fn get(&self, bank_id: u64) -> Option<&Arc> { - self.banks.get(&bank_id) + pub fn get(&self, bank_slot: u64) -> Option<&Arc> { + self.banks.get(&bank_slot) } pub fn new_from_banks(initial_banks: &[Arc]) -> Self { @@ -62,13 +62,13 @@ impl BankForks { } // TODO: use the bank's own ID instead of receiving a parameter? - pub fn insert(&mut self, bank_id: u64, bank: Bank) { + pub fn insert(&mut self, bank_slot: u64, bank: Bank) { let mut bank = Arc::new(bank); - assert_eq!(bank_id, bank.slot()); - let prev = self.banks.insert(bank_id, bank.clone()); + assert_eq!(bank_slot, bank.slot()); + let prev = self.banks.insert(bank_slot, bank.clone()); assert!(prev.is_none()); - if bank_id > self.working_bank.slot() { + if bank_slot > self.working_bank.slot() { self.working_bank = bank.clone() } diff --git a/core/src/blocktree_processor.rs b/core/src/blocktree_processor.rs index 2d5cfa7043..eb99c32482 100644 --- a/core/src/blocktree_processor.rs +++ b/core/src/blocktree_processor.rs @@ -98,7 +98,7 @@ fn process_block(bank: &Bank, entries: &[Entry]) -> Result<()> { #[derive(Debug, PartialEq)] pub struct BankForksInfo { - pub bank_id: u64, + pub bank_slot: u64, pub entry_height: u64, } @@ -190,7 +190,7 @@ pub fn process_blocktree( })?; let bfi = BankForksInfo { - bank_id: slot, + bank_slot: slot, entry_height: starting_entry_height, }; fork_info.push((starting_bank, bfi)); @@ -204,7 +204,7 @@ pub fn process_blocktree( // Reached the end of this fork. Record the final entry height and last entry.hash let bfi = BankForksInfo { - bank_id: slot, + bank_slot: slot, entry_height, }; fork_info.push((bank, bfi)); @@ -316,7 +316,7 @@ mod tests { assert_eq!( bank_forks_info[0], BankForksInfo { - bank_id: 1, // never finished first slot + bank_slot: 1, // never finished first slot entry_height: ticks_per_slot, } ); @@ -373,21 +373,21 @@ mod tests { assert_eq!( bank_forks_info[0], BankForksInfo { - bank_id: 3, // Fork 1's head is slot 3 + bank_slot: 3, // Fork 1's head is slot 3 entry_height: ticks_per_slot * 4, } ); assert_eq!( bank_forks_info[1], BankForksInfo { - bank_id: 4, // Fork 2's head is slot 4 + bank_slot: 4, // Fork 2's head is slot 4 entry_height: ticks_per_slot * 3, } ); // Ensure bank_forks holds the right banks for info in bank_forks_info { - assert_eq!(bank_forks[info.bank_id].slot(), info.bank_id); + assert_eq!(bank_forks[info.bank_slot].slot(), info.bank_slot); } } @@ -493,7 +493,7 @@ mod tests { assert_eq!( bank_forks_info[0], BankForksInfo { - bank_id: 1, + bank_slot: 1, entry_height, } ); @@ -518,7 +518,7 @@ mod tests { assert_eq!( bank_forks_info[0], BankForksInfo { - bank_id: 0, + bank_slot: 0, entry_height: 1, } ); diff --git a/core/src/fullnode.rs b/core/src/fullnode.rs index cee23c49e9..2a7cd791d1 100644 --- a/core/src/fullnode.rs +++ b/core/src/fullnode.rs @@ -120,7 +120,7 @@ impl Fullnode { let exit = Arc::new(AtomicBool::new(false)); let bank_info = &bank_forks_info[0]; - let bank = bank_forks[bank_info.bank_id].clone(); + let bank = bank_forks[bank_info.bank_slot].clone(); info!( "starting PoH... {} {}", diff --git a/core/src/poh_recorder.rs b/core/src/poh_recorder.rs index 245a4a5330..b6291daaed 100644 --- a/core/src/poh_recorder.rs +++ b/core/src/poh_recorder.rs @@ -126,7 +126,7 @@ impl PohRecorder { .count(); let e = if cnt > 0 { debug!( - "flush_cache: bank_id: {} tick_height: {} max: {} sending: {}", + "flush_cache: bank_slot: {} tick_height: {} max: {} sending: {}", working_bank.bank.slot(), working_bank.bank.tick_height(), working_bank.max_tick_height, diff --git a/core/src/replay_stage.rs b/core/src/replay_stage.rs index ac3cc807d4..712dec1007 100644 --- a/core/src/replay_stage.rs +++ b/core/src/replay_stage.rs @@ -95,8 +95,8 @@ impl ReplayStage { let active_banks = bank_forks.read().unwrap().active_banks(); trace!("active banks {:?}", active_banks); let mut votable: Vec = vec![]; - for bank_id in &active_banks { - let bank = bank_forks.read().unwrap().get(*bank_id).unwrap().clone(); + for bank_slot in &active_banks { + let bank = bank_forks.read().unwrap().get(*bank_slot).unwrap().clone(); if !Self::is_tpu(&bank, my_id) { Self::replay_blocktree_into_bank( &bank, @@ -105,12 +105,12 @@ impl ReplayStage { &forward_entry_sender, )?; } - let max_tick_height = (*bank_id + 1) * bank.ticks_per_slot() - 1; + let max_tick_height = (*bank_slot + 1) * bank.ticks_per_slot() - 1; if bank.tick_height() == max_tick_height { bank.freeze(); info!("bank frozen {}", bank.slot()); - votable.push(*bank_id); - progress.remove(bank_id); + votable.push(*bank_slot); + progress.remove(bank_slot); let id = leader_schedule_utils::slot_leader_at(bank.slot(), &bank); if let Err(e) = slot_full_sender.send((bank.slot(), id)) { info!("{} slot_full alert failed: {:?}", my_id, e); @@ -228,11 +228,11 @@ impl ReplayStage { blocktree: &Blocktree, progress: &mut HashMap, ) -> result::Result<(Vec, usize)> { - let bank_id = bank.slot(); + let bank_slot = bank.slot(); let bank_progress = &mut progress - .entry(bank_id) + .entry(bank_slot) .or_insert((bank.last_blockhash(), 0)); - blocktree.get_slot_entries_with_blob_count(bank_id, bank_progress.1 as u64, None) + blocktree.get_slot_entries_with_blob_count(bank_slot, bank_progress.1 as u64, None) } pub fn replay_entries_into_bank( @@ -292,10 +292,10 @@ 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(); - let frozen_bank_ids: Vec = frozen_banks.keys().cloned().collect(); - trace!("frozen_banks {:?}", frozen_bank_ids); + let frozen_bank_slots: Vec = frozen_banks.keys().cloned().collect(); + trace!("frozen_banks {:?}", frozen_bank_slots); let next_slots = blocktree - .get_slots_since(&frozen_bank_ids) + .get_slots_since(&frozen_bank_slots) .expect("Db error"); trace!("generate new forks {:?}", next_slots); for (parent_id, children) in next_slots { diff --git a/core/src/tvu.rs b/core/src/tvu.rs index b48d180a74..c3c35c83c9 100644 --- a/core/src/tvu.rs +++ b/core/src/tvu.rs @@ -206,7 +206,7 @@ pub mod tests { let bank_forks = BankForks::new(0, Bank::new(&genesis_block)); let bank_forks_info = vec![BankForksInfo { - bank_id: 0, + bank_slot: 0, entry_height: 0, }]; diff --git a/tests/tvu.rs b/tests/tvu.rs index 8d369f179d..6f05ef0335 100644 --- a/tests/tvu.rs +++ b/tests/tvu.rs @@ -90,7 +90,7 @@ fn test_replay() { let blockhash = bank.last_blockhash(); let bank_forks = BankForks::new(0, bank); let bank_forks_info = vec![BankForksInfo { - bank_id: 0, + bank_slot: 0, entry_height: 0, }];