Skip to content
Snippets Groups Projects
Commit 5035f18a authored by Arkadiy Paronyan's avatar Arkadiy Paronyan Committed by GitHub
Browse files

Specialized network() (#352)

parent 07fbd871
No related merge requests found
......@@ -60,6 +60,7 @@ pub use client::ExecutionStrategy;
pub type ChainSpec = service::ChainSpec<GenesisConfig>;
/// Polkadot client type for specialised `Components`.
pub type ComponentClient<C> = Client<<C as Components>::Backend, <C as Components>::Executor, Block>;
pub type NetworkService = network::Service<Block, <Factory as service::ServiceFactory>::NetworkProtocol>;
/// A collection of type to generalise Polkadot specific components over full / light client.
pub trait Components: service::Components {
......@@ -134,6 +135,7 @@ impl service::ServiceFactory for Factory {
pub struct Service<C: Components> {
inner: service::Service<C>,
client: Arc<ComponentClient<C>>,
network: Arc<NetworkService>,
api: Arc<<C as Components>::Api>,
_consensus: Option<consensus::Service>,
}
......@@ -143,6 +145,10 @@ impl <C: Components> Service<C> {
self.client.clone()
}
pub fn network(&self) -> Arc<NetworkService> {
self.network.clone()
}
pub fn api(&self) -> Arc<<C as Components>::Api> {
self.api.clone()
}
......@@ -156,6 +162,7 @@ pub fn new_light(config: Configuration<GenesisConfig>, executor: TaskExecutor)
let api = Arc::new(RemotePolkadotApiWrapper(service.client()));
Ok(Service {
client: service.client(),
network: service.network(),
api: api,
inner: service,
_consensus: None,
......@@ -192,6 +199,7 @@ pub fn new_full(config: Configuration<GenesisConfig>, executor: TaskExecutor)
Ok(Service {
client: service.client(),
network: service.network(),
api: service.client(),
inner: service,
_consensus: consensus,
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment