bank::get_rent_collector_from_parent (#23016)
This commit is contained in:
parent
ae175a026b
commit
205cd4609b
|
@ -1509,6 +1509,10 @@ impl Bank {
|
|||
)
|
||||
}
|
||||
|
||||
fn get_rent_collector_from(rent_collector: &RentCollector, epoch: Epoch) -> RentCollector {
|
||||
rent_collector.clone_with_epoch(epoch)
|
||||
}
|
||||
|
||||
fn _new_from_parent(
|
||||
parent: &Arc<Bank>,
|
||||
collector_id: &Pubkey,
|
||||
|
@ -1636,7 +1640,7 @@ impl Bank {
|
|||
slots_per_year: parent.slots_per_year,
|
||||
epoch_schedule,
|
||||
collected_rent: AtomicU64::new(0),
|
||||
rent_collector: parent.rent_collector.clone_with_epoch(epoch),
|
||||
rent_collector: Self::get_rent_collector_from(&parent.rent_collector, epoch),
|
||||
max_tick_height: (slot + 1) * parent.ticks_per_slot,
|
||||
block_height: parent.block_height + 1,
|
||||
fee_calculator,
|
||||
|
@ -1947,7 +1951,7 @@ impl Bank {
|
|||
fee_rate_governor: fields.fee_rate_governor,
|
||||
collected_rent: AtomicU64::new(fields.collected_rent),
|
||||
// clone()-ing is needed to consider a gated behavior in rent_collector
|
||||
rent_collector: fields.rent_collector.clone_with_epoch(fields.epoch),
|
||||
rent_collector: Self::get_rent_collector_from(&fields.rent_collector, fields.epoch),
|
||||
epoch_schedule: fields.epoch_schedule,
|
||||
inflation: Arc::new(RwLock::new(fields.inflation)),
|
||||
stakes_cache: StakesCache::new(fields.stakes),
|
||||
|
|
|
@ -54,7 +54,20 @@ impl RentCollector {
|
|||
}
|
||||
|
||||
pub fn clone_with_epoch(&self, epoch: Epoch) -> Self {
|
||||
self.clone_with_epoch_and_rate(epoch, self.rent.lamports_per_byte_year)
|
||||
}
|
||||
|
||||
pub fn clone_with_epoch_and_rate(&self, epoch: Epoch, lamports_per_byte_year: u64) -> Self {
|
||||
let rent = if lamports_per_byte_year != self.rent.lamports_per_byte_year {
|
||||
Rent {
|
||||
lamports_per_byte_year,
|
||||
..self.rent
|
||||
}
|
||||
} else {
|
||||
self.rent
|
||||
};
|
||||
Self {
|
||||
rent,
|
||||
epoch,
|
||||
..self.clone()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue