Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Overseer changes
Browse files Browse the repository at this point in the history
  • Loading branch information
expenses committed Jun 2, 2020
1 parent 289953d commit 76156d5
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions overseer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ futures = "0.3.5"
log = "0.4.8"
futures-timer = "3.0.2"
streamunordered = "0.5.1"
polkadot-primitives = { path = "../primitives" }
polkadot-statement-table = { path = "../statement-table" }

[dev-dependencies]
futures = { version = "0.3.5", features = ["thread-pool"] }
Expand Down
34 changes: 32 additions & 2 deletions overseer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ use futures::{
};
use futures_timer::Delay;
use streamunordered::{StreamYield, StreamUnordered};
use polkadot_primitives::Hash;
use polkadot_statement_table::SignedStatement;

/// An error type that describes faults that may happen
///
Expand Down Expand Up @@ -225,9 +227,9 @@ pub struct SubsystemContext<M: Debug>{
#[derive(Debug)]
pub enum OverseerSignal {
/// `Subsystem` should start working.
StartWork,
StartWork(Hash),
/// `Subsystem` should stop working.
StopWork,
StopWork(Hash),
/// Conclude the work of the `Overseer` and all `Subsystem`s.
Conclude,
}
Expand All @@ -249,13 +251,24 @@ pub enum CandidateBackingSubsystemMessage {
Second,
}


#[derive(Debug)]
/// A message type used by the StatementGossip [`Subsystem`].
///
/// [`Subsystem`]: trait.Subsystem.html
pub enum StatementGossipSubsystemMessage {
ToGossip { relay_parent: Hash, statement: SignedStatement },
Received { relay_parent: Hash, statement: SignedStatement }
}

/// A message type tying together all message types that are used across [`Subsystem`]s.
///
/// [`Subsystem`]: trait.Subsystem.html
#[derive(Debug)]
pub enum AllMessages {
Validation(ValidationSubsystemMessage),
CandidateBacking(CandidateBackingSubsystemMessage),
StatementGossip(StatementGossipSubsystemMessage)
}

/// A message type that a [`Subsystem`] receives from the [`Overseer`].
Expand Down Expand Up @@ -355,6 +368,9 @@ pub struct Overseer<S: Spawn> {
/// A candidate backing subsystem
candidate_backing_subsystem: OverseenSubsystem<CandidateBackingSubsystemMessage>,

/// A statement gossip subsystem
statement_gossip_subsystem: OverseenSubsystem<StatementGossipSubsystemMessage>,

/// Spawner to spawn tasks to.
s: S,

Expand Down Expand Up @@ -473,6 +489,7 @@ where
pub fn new(
validation: Box<dyn Subsystem<ValidationSubsystemMessage> + Send>,
candidate_backing: Box<dyn Subsystem<CandidateBackingSubsystemMessage> + Send>,
statement_gossip: Box<dyn Subsystem<StatementGossipSubsystemMessage> + Send>,
mut s: S,
) -> SubsystemResult<(Self, OverseerHandler)> {
let (events_tx, events_rx) = mpsc::channel(CHANNEL_CAPACITY);
Expand All @@ -498,9 +515,17 @@ where
candidate_backing,
)?;

let statement_gossip_subsystem = spawn(
&mut s,
&mut running_subsystems,
&mut running_subsystems_rx,
statement_gossip,
)?;

let this = Self {
validation_subsystem,
candidate_backing_subsystem,
statement_gossip_subsystem,
s,
running_subsystems,
running_subsystems_rx,
Expand Down Expand Up @@ -588,6 +613,11 @@ where
let _ = s.tx.send(FromOverseer::Communication { msg }).await;
}
}
AllMessages::StatementGossip(msg) => {
if let Some(ref mut s) = self.statement_gossip_subsystem.instance {
let _ = s.tx.send(FromOverseer::Communication { msg }).await;
}
}
}
}

Expand Down

0 comments on commit 76156d5

Please sign in to comment.