Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions collator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,19 @@ pub trait Network: Send + Sync {
/// dropped when it is not required anymore. Otherwise, it will stick around in memory
/// infinitely.
fn checked_statements(&self, relay_parent: Hash) -> Pin<Box<dyn Stream<Item=SignedStatement> + Send>>;

/// Returns the `NetworkService`
fn network_service(&self) -> Arc<polkadot_network::PolkadotNetworkService>;
}

impl Network for polkadot_network::protocol::Service {
fn checked_statements(&self, relay_parent: Hash) -> Pin<Box<dyn Stream<Item=SignedStatement> + Send>> {
polkadot_network::protocol::Service::checked_statements(self, relay_parent).boxed()
}

fn network_service(&self) -> Arc<polkadot_network::PolkadotNetworkService> {
polkadot_network::protocol::Service::network_service(self)
}
}

/// Error to return when the head data was invalid.
Expand Down
7 changes: 7 additions & 0 deletions network/src/protocol/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,13 @@ impl<N> Clone for Service<N> {
}
}

impl<N> Service<N> {
/// Returns the `NetworkService`
pub fn network_service(&self) -> Arc<N> {
self.network_service.clone()
}
}

/// Registers the protocol.
///
/// You are very strongly encouraged to call this method very early on. Any connection open
Expand Down