Skip to content

Commit

Permalink
Start adding slot stream
Browse files Browse the repository at this point in the history
  • Loading branch information
paulhauner committed Jan 15, 2021
1 parent 10f181d commit f61c4e0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions common/slot_clock/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ types = { path = "../../consensus/types" }
lazy_static = "1.4.0"
lighthouse_metrics = { path = "../lighthouse_metrics" }
parking_lot = "0.11.0"
tokio = { version = "0.3.2", features = ["full"] }
15 changes: 15 additions & 0 deletions common/slot_clock/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,19 @@ mod manual_slot_clock;
mod metrics;
mod system_time_slot_clock;

use std::future::Future;
use std::time::Duration;
use tokio::time::sleep;

pub use crate::manual_slot_clock::ManualSlotClock;
pub use crate::manual_slot_clock::ManualSlotClock as TestingSlotClock;
pub use crate::system_time_slot_clock::SystemTimeSlotClock;
pub use metrics::scrape_for_metrics;
pub use tokio::sync::mpsc::{self, Receiver};
pub use types::Slot;

pub const SLOT_STREAM_CHANNEL_SIZE: usize = 16_384;

/// A clock that reports the current slot.
///
/// The clock is not required to be monotonically increasing and may go backwards.
Expand Down Expand Up @@ -73,3 +78,13 @@ pub trait SlotClock: Send + Sync + Sized {
.or_else(|| Some(self.genesis_slot()))
}
}

pub async fn slot_stream<S: SlotClock>(
slot_clock: S,
) -> (Receiver<Slot>, impl Future<Output = ()>) {
let (tx, rx) = mpsc::channel(SLOT_STREAM_CHANNEL_SIZE);

let future = async move { todo!() };

(rx, future)
}

0 comments on commit f61c4e0

Please sign in to comment.