mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-23 12:01:07 +00:00
Specialized network() (#352)
This commit is contained in:
@@ -60,6 +60,7 @@ pub use client::ExecutionStrategy;
|
|||||||
pub type ChainSpec = service::ChainSpec<GenesisConfig>;
|
pub type ChainSpec = service::ChainSpec<GenesisConfig>;
|
||||||
/// Polkadot client type for specialised `Components`.
|
/// Polkadot client type for specialised `Components`.
|
||||||
pub type ComponentClient<C> = Client<<C as Components>::Backend, <C as Components>::Executor, Block>;
|
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.
|
/// A collection of type to generalise Polkadot specific components over full / light client.
|
||||||
pub trait Components: service::Components {
|
pub trait Components: service::Components {
|
||||||
@@ -134,6 +135,7 @@ impl service::ServiceFactory for Factory {
|
|||||||
pub struct Service<C: Components> {
|
pub struct Service<C: Components> {
|
||||||
inner: service::Service<C>,
|
inner: service::Service<C>,
|
||||||
client: Arc<ComponentClient<C>>,
|
client: Arc<ComponentClient<C>>,
|
||||||
|
network: Arc<NetworkService>,
|
||||||
api: Arc<<C as Components>::Api>,
|
api: Arc<<C as Components>::Api>,
|
||||||
_consensus: Option<consensus::Service>,
|
_consensus: Option<consensus::Service>,
|
||||||
}
|
}
|
||||||
@@ -143,6 +145,10 @@ impl <C: Components> Service<C> {
|
|||||||
self.client.clone()
|
self.client.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn network(&self) -> Arc<NetworkService> {
|
||||||
|
self.network.clone()
|
||||||
|
}
|
||||||
|
|
||||||
pub fn api(&self) -> Arc<<C as Components>::Api> {
|
pub fn api(&self) -> Arc<<C as Components>::Api> {
|
||||||
self.api.clone()
|
self.api.clone()
|
||||||
}
|
}
|
||||||
@@ -156,6 +162,7 @@ pub fn new_light(config: Configuration<GenesisConfig>, executor: TaskExecutor)
|
|||||||
let api = Arc::new(RemotePolkadotApiWrapper(service.client()));
|
let api = Arc::new(RemotePolkadotApiWrapper(service.client()));
|
||||||
Ok(Service {
|
Ok(Service {
|
||||||
client: service.client(),
|
client: service.client(),
|
||||||
|
network: service.network(),
|
||||||
api: api,
|
api: api,
|
||||||
inner: service,
|
inner: service,
|
||||||
_consensus: None,
|
_consensus: None,
|
||||||
@@ -192,6 +199,7 @@ pub fn new_full(config: Configuration<GenesisConfig>, executor: TaskExecutor)
|
|||||||
|
|
||||||
Ok(Service {
|
Ok(Service {
|
||||||
client: service.client(),
|
client: service.client(),
|
||||||
|
network: service.network(),
|
||||||
api: service.client(),
|
api: service.client(),
|
||||||
inner: service,
|
inner: service,
|
||||||
_consensus: consensus,
|
_consensus: consensus,
|
||||||
|
|||||||
Reference in New Issue
Block a user