[][src]Trait substrate_service::AbstractService

pub trait AbstractService: 'static + Future<Item = (), Error = Error> + Executor<Box<dyn Future<Item = (), Error = ()> + Send>> + Send {
    type Block: BlockT<Hash = H256>;
    type Backend: 'static + Backend<Self::Block, Blake2Hasher>;
    type CallExecutor: 'static + CallExecutor<Self::Block, Blake2Hasher> + Send + Sync + Clone;
    type RuntimeApi: Send + Sync;
    type SelectChain: SelectChain<Self::Block>;
    type TransactionPoolApi: ChainApi<Block = Self::Block>;
    type NetworkSpecialization: NetworkSpecialization<Self::Block>;
    fn telemetry_on_connect_stream(&self) -> UnboundedReceiver<()>;
fn telemetry(&self) -> Option<Telemetry>;
fn spawn_task(
        &self,
        task: impl Future<Item = (), Error = ()> + Send + 'static
    );
fn spawn_essential_task(
        &self,
        task: impl Future<Item = (), Error = ()> + Send + 'static
    );
fn spawn_task_handle(&self) -> SpawnTaskHandle;
fn keystore(&self) -> KeyStorePtr;
fn rpc_query(
        &self,
        mem: &RpcSession,
        request: &str
    ) -> Box<dyn Future<Item = Option<String>, Error = ()> + Send>;
fn client(
        &self
    ) -> Arc<Client<Self::Backend, Self::CallExecutor, Self::Block, Self::RuntimeApi>>;
fn select_chain(&self) -> Option<Self::SelectChain>;
fn network(
        &self
    ) -> Arc<NetworkService<Self::Block, Self::NetworkSpecialization, H256>>;
fn network_status(
        &self,
        interval: Duration
    ) -> UnboundedReceiver<(NetworkStatus<Self::Block>, NetworkState)>;
fn transaction_pool(&self) -> Arc<TransactionPool<Self::TransactionPoolApi>>;
fn on_exit(&self) -> Exit; }

Abstraction over a Substrate service.

Associated Types

type Block: BlockT<Hash = H256>

Type of block of this chain.

type Backend: 'static + Backend<Self::Block, Blake2Hasher>

Backend storage for the client.

type CallExecutor: 'static + CallExecutor<Self::Block, Blake2Hasher> + Send + Sync + Clone

How to execute calls towards the runtime.

type RuntimeApi: Send + Sync

API that the runtime provides.

type SelectChain: SelectChain<Self::Block>

Chain selection algorithm.

type TransactionPoolApi: ChainApi<Block = Self::Block>

API of the transaction pool.

type NetworkSpecialization: NetworkSpecialization<Self::Block>

Network specialization.

Loading content...

Required methods

fn telemetry_on_connect_stream(&self) -> UnboundedReceiver<()>

Get event stream for telemetry connection established events.

fn telemetry(&self) -> Option<Telemetry>

return a shared instance of Telemetry (if enabled)

fn spawn_task(&self, task: impl Future<Item = (), Error = ()> + Send + 'static)

Spawns a task in the background that runs the future passed as parameter.

fn spawn_essential_task(
    &self,
    task: impl Future<Item = (), Error = ()> + Send + 'static
)

Spawns a task in the background that runs the future passed as parameter. The given task is considered essential, i.e. if it errors we trigger a service exit.

fn spawn_task_handle(&self) -> SpawnTaskHandle

Returns a handle for spawning tasks.

fn keystore(&self) -> KeyStorePtr

Returns the keystore that stores keys.

fn rpc_query(
    &self,
    mem: &RpcSession,
    request: &str
) -> Box<dyn Future<Item = Option<String>, Error = ()> + Send>

Starts an RPC query.

The query is passed as a string and must be a JSON text similar to what an HTTP client would for example send.

Returns a Future that contains the optional response.

If the request subscribes you to events, the Sender in the RpcSession object is used to send back spontaneous events.

fn client(
    &self
) -> Arc<Client<Self::Backend, Self::CallExecutor, Self::Block, Self::RuntimeApi>>

Get shared client instance.

fn select_chain(&self) -> Option<Self::SelectChain>

Get clone of select chain.

fn network(
    &self
) -> Arc<NetworkService<Self::Block, Self::NetworkSpecialization, H256>>

Get shared network instance.

fn network_status(
    &self,
    interval: Duration
) -> UnboundedReceiver<(NetworkStatus<Self::Block>, NetworkState)>

Returns a receiver that periodically receives a status of the network.

fn transaction_pool(&self) -> Arc<TransactionPool<Self::TransactionPoolApi>>

Get shared transaction pool instance.

fn on_exit(&self) -> Exit

Get a handle to a future that will resolve on exit.

Loading content...

Implementors

impl<TBl, TBackend, TExec, TRtApi, TSc, TNetSpec, TExPoolApi, TOc> AbstractService for Service<TBl, Client<TBackend, TExec, TBl, TRtApi>, TSc, NetworkStatus<TBl>, NetworkService<TBl, TNetSpec, H256>, TransactionPool<TExPoolApi>, TOc> where
    TBl: BlockT<Hash = H256>,
    TBackend: 'static + Backend<TBl, Blake2Hasher>,
    TExec: 'static + CallExecutor<TBl, Blake2Hasher> + Send + Sync + Clone,
    TRtApi: 'static + Send + Sync,
    TSc: SelectChain<TBl> + 'static + Clone + Send,
    TExPoolApi: 'static + ChainApi<Block = TBl>,
    TOc: 'static + Send + Sync,
    TNetSpec: NetworkSpecialization<TBl>, 
[src]

type Block = TBl

type Backend = TBackend

type CallExecutor = TExec

type RuntimeApi = TRtApi

type SelectChain = TSc

type TransactionPoolApi = TExPoolApi

type NetworkSpecialization = TNetSpec

Loading content...