>;
}
impl Network for ValidationNetwork
where
P: 'static + Send + Sync,
SP: 'static + Spawn + Clone + Send + Sync,
{
fn collator_id_to_peer_id(&self, collator_id: CollatorId) ->
Box> + Send>
{
Box::new(Self::collator_id_to_peer_id(self, collator_id))
}
fn checked_statements(&self, relay_parent: Hash) -> Box> {
Box::new(Self::checked_statements(self, relay_parent))
}
}
/// Error to return when the head data was invalid.
#[derive(Clone, Copy, Debug)]
pub struct InvalidHead;
/// Collation errors.
#[derive(Debug)]
pub enum Error {
/// Error on the relay-chain side of things.
Polkadot(String),
/// Error on the collator side of things.
Collator(InvalidHead),
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
Error::Polkadot(ref err) => write!(f, "Polkadot node error: {}", err),
Error::Collator(_) => write!(f, "Collator node error: Invalid head data"),
}
}
}
/// The Polkadot client type.
pub type PolkadotClient = sc_client::Client;
/// Something that can build a `ParachainContext`.
pub trait BuildParachainContext {
/// The parachain context produced by the `build` function.
type ParachainContext: self::ParachainContext;
/// Build the `ParachainContext`.
fn build(
self,
client: Arc>,
spawner: SP,
network: Arc,
) -> Result
where
PolkadotClient: ProvideRuntimeApi,
as ProvideRuntimeApi>::Api: RuntimeApiCollection,
// Rust bug: https://github.com/rust-lang/rust/issues/24159
< as ProvideRuntimeApi>::Api as sp_api::ApiExt>::StateBackend:
sp_api::StateBackend,
Extrinsic: codec::Codec + Send + Sync + 'static,
E: sc_client::CallExecutor + Clone + Send + Sync + 'static,
SP: Spawn + Clone + Send + Sync + 'static,
R: Send + Sync + 'static,
B: sc_client_api::Backend + 'static,
// Rust bug: https://github.com/rust-lang/rust/issues/24159
B::State: sp_api::StateBackend;
}
/// Parachain context needed for collation.
///
/// This can be implemented through an externally attached service or a stub.
/// This is expected to be a lightweight, shared type like an Arc.
pub trait ParachainContext: Clone {
type ProduceCandidate: Future