Skip to content

Commit

Permalink
remove clone in LeaderScheduleCache::new
Browse files Browse the repository at this point in the history
  • Loading branch information
apfitzge committed Oct 19, 2023
1 parent 1d5d2e7 commit 0dfaf6f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions ledger/src/leader_schedule_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl LeaderScheduleCache {
pub fn new(epoch_schedule: EpochSchedule, root_bank: &Bank) -> Self {
let cache = Self {
cached_schedules: RwLock::new((HashMap::new(), VecDeque::new())),
epoch_schedule: epoch_schedule.clone(),
epoch_schedule,
max_epoch: RwLock::new(0),
max_schedules: CacheCapacity::default(),
fixed_schedule: None,
Expand All @@ -56,9 +56,11 @@ impl LeaderScheduleCache {
cache.set_root(root_bank);

// Calculate the schedule for all epochs between 0 and leader_schedule_epoch(root)
let leader_schedule_epoch = epoch_schedule.get_leader_schedule_epoch(root_bank.slot());
let leader_schedule_epoch = cache
.epoch_schedule
.get_leader_schedule_epoch(root_bank.slot());
for epoch in 0..leader_schedule_epoch {
let first_slot_in_epoch = epoch_schedule.get_first_slot_in_epoch(epoch);
let first_slot_in_epoch = cache.epoch_schedule.get_first_slot_in_epoch(epoch);
cache.slot_leader_at(first_slot_in_epoch, Some(root_bank));
}
cache
Expand Down

0 comments on commit 0dfaf6f

Please sign in to comment.