remove max_tick_height replicode (#3765)
This commit is contained in:
parent
bd1db51e07
commit
de52747950
|
@ -45,7 +45,7 @@ impl Broadcast {
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let timer = Duration::new(1, 0);
|
let timer = Duration::new(1, 0);
|
||||||
let (mut bank, entries) = receiver.recv_timeout(timer)?;
|
let (mut bank, entries) = receiver.recv_timeout(timer)?;
|
||||||
let mut max_tick_height = (bank.slot() + 1) * bank.ticks_per_slot() - 1;
|
let mut max_tick_height = bank.max_tick_height();
|
||||||
|
|
||||||
let now = Instant::now();
|
let now = Instant::now();
|
||||||
let mut num_entries = entries.len();
|
let mut num_entries = entries.len();
|
||||||
|
@ -62,7 +62,7 @@ impl Broadcast {
|
||||||
num_entries = 0;
|
num_entries = 0;
|
||||||
ventries.clear();
|
ventries.clear();
|
||||||
bank = same_bank.clone();
|
bank = same_bank.clone();
|
||||||
max_tick_height = (bank.slot() + 1) * bank.ticks_per_slot() - 1;
|
max_tick_height = bank.max_tick_height();
|
||||||
}
|
}
|
||||||
num_entries += entries.len();
|
num_entries += entries.len();
|
||||||
last_tick = entries.last().map(|v| v.1).unwrap_or(0);
|
last_tick = entries.last().map(|v| v.1).unwrap_or(0);
|
||||||
|
|
|
@ -136,6 +136,9 @@ pub struct Bank {
|
||||||
/// Bank tick height
|
/// Bank tick height
|
||||||
tick_height: AtomicUsize, // TODO: Use AtomicU64 if/when available
|
tick_height: AtomicUsize, // TODO: Use AtomicU64 if/when available
|
||||||
|
|
||||||
|
// Bank max_tick_height
|
||||||
|
max_tick_height: u64,
|
||||||
|
|
||||||
/// The number of ticks in each slot.
|
/// The number of ticks in each slot.
|
||||||
ticks_per_slot: u64,
|
ticks_per_slot: u64,
|
||||||
|
|
||||||
|
@ -209,6 +212,8 @@ impl Bank {
|
||||||
bank.epoch_schedule = parent.epoch_schedule;
|
bank.epoch_schedule = parent.epoch_schedule;
|
||||||
|
|
||||||
bank.slot = slot;
|
bank.slot = slot;
|
||||||
|
bank.max_tick_height = (bank.slot + 1) * bank.ticks_per_slot - 1;
|
||||||
|
|
||||||
bank.parent = RwLock::new(Some(parent.clone()));
|
bank.parent = RwLock::new(Some(parent.clone()));
|
||||||
bank.parent_hash = parent.hash();
|
bank.parent_hash = parent.hash();
|
||||||
bank.collector_id = *collector_id;
|
bank.collector_id = *collector_id;
|
||||||
|
@ -345,6 +350,7 @@ impl Bank {
|
||||||
.genesis_hash(&genesis_block.hash());
|
.genesis_hash(&genesis_block.hash());
|
||||||
|
|
||||||
self.ticks_per_slot = genesis_block.ticks_per_slot;
|
self.ticks_per_slot = genesis_block.ticks_per_slot;
|
||||||
|
self.max_tick_height = (self.slot + 1) * self.ticks_per_slot - 1;
|
||||||
|
|
||||||
// make bank 0 votable
|
// make bank 0 votable
|
||||||
self.is_delta.store(true, Ordering::Relaxed);
|
self.is_delta.store(true, Ordering::Relaxed);
|
||||||
|
@ -928,6 +934,11 @@ impl Bank {
|
||||||
self.tick_height.load(Ordering::SeqCst) as u64
|
self.tick_height.load(Ordering::SeqCst) as u64
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Return this bank's max_tick_height
|
||||||
|
pub fn max_tick_height(&self) -> u64 {
|
||||||
|
self.max_tick_height
|
||||||
|
}
|
||||||
|
|
||||||
/// Return the number of slots per epoch for the given epoch
|
/// Return the number of slots per epoch for the given epoch
|
||||||
pub fn get_slots_in_epoch(&self, epoch: u64) -> u64 {
|
pub fn get_slots_in_epoch(&self, epoch: u64) -> u64 {
|
||||||
self.epoch_schedule.get_slots_in_epoch(epoch)
|
self.epoch_schedule.get_slots_in_epoch(epoch)
|
||||||
|
|
Loading…
Reference in New Issue