Skip to content
Permalink
Browse files

add some more info in the leader's schedule

  • Loading branch information...
NicolasDP committed May 14, 2019
1 parent 39eefd8 commit 829f6cf42775548be6cced0d86585e92fcd510f5
Showing with 13 additions and 3 deletions.
  1. +12 −3 src/leadership/schedule.rs
  2. +1 −0 src/leadership/task.rs
@@ -12,24 +12,33 @@ use tokio::{
};

/// structure to prepare the schedule of a leader
///
/// This object will generate a steam of events at precise times
/// where the `Leader` is expected to create a block.
pub struct LeaderSchedule {
events: DelayQueue<ScheduledEvent>,
}

/// a scheduled event where the `Leader` is expected to create a block
pub struct ScheduledEvent {
pub leader_output: LeaderOutput,
pub date: BlockDate,
pub expected_time: SystemTime,
}

impl LeaderSchedule {
/// create a new schedule based on the [`TaskParameters`] and the `Leader`
/// settings.
///
/// [`TaskParameters`]: ./struct.TaskParameters.html
///
pub fn new(logger: Logger, leader: &Leader, task_parameters: &TaskParameters) -> Self {
// TODO: use parameter's number of slot per epoch
let number_of_slots_per_epoch = 100;
let era = task_parameters.leadership.era();
let number_of_slots_per_epoch = era.slots_per_epoch();
let now = std::time::SystemTime::now();

let mut schedule = LeaderSchedule {
events: DelayQueue::with_capacity(number_of_slots_per_epoch),
events: DelayQueue::with_capacity(number_of_slots_per_epoch as usize),
};

let logger = Logger::root(
@@ -56,6 +56,7 @@ impl Task {
let logger = Logger::root(
logger,
o!(
"task" => "Leader Task",
// TODO: add some general context information here (leader alias?)
),
);

0 comments on commit 829f6cf

Please sign in to comment.
You can’t perform that action at this time.