[][src]Trait sc_service::AbstractService

pub trait AbstractService: 'static + Future<Output = Result<(), Error>> + Spawn + Send + Unpin {
    type Block: BlockT;
    type Backend: 'static + Backend<Self::Block>;
    type CallExecutor: 'static + CallExecutor<Self::Block> + Send + Sync + Clone;
    type RuntimeApi: Send + Sync;
    type SelectChain: SelectChain<Self::Block>;
    type TransactionPool: TransactionPool<Block = Self::Block> + MallocSizeOfWasm;
    fn telemetry_on_connect_stream(&self) -> TracingUnboundedReceiver<()>;
fn telemetry(&self) -> Option<Telemetry>;
fn spawn_task(
        &self,
        name: impl Into<Cow<'static, str>>,
        task: impl Future<Output = ()> + Send + 'static
    );
fn spawn_essential_task(
        &self,
        name: impl Into<Cow<'static, str>>,
        task: impl Future<Output = ()> + Send + 'static
    );
fn spawn_task_handle(&self) -> SpawnTaskHandle;
fn keystore(&self) -> KeyStorePtr;
fn rpc_query(
        &self,
        mem: &RpcSession,
        request: &str
    ) -> Pin<Box<dyn Future<Output = Option<String>> + 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::Block as BlockT>::Hash>>;
fn network_status(
        &self,
        interval: Duration
    ) -> TracingUnboundedReceiver<(NetworkStatus<Self::Block>, NetworkState)>;
fn transaction_pool(&self) -> Arc<Self::TransactionPool>;
fn on_exit(&self) -> Exit;
fn prometheus_registry(&self) -> Option<Registry>; }

Abstraction over a Substrate service.

Associated Types

type Block: BlockT

Type of block of this chain.

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

Backend storage for the client.

type CallExecutor: 'static + CallExecutor<Self::Block> + 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 TransactionPool: TransactionPool<Block = Self::Block> + MallocSizeOfWasm

Transaction pool.

Loading content...

Required methods

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

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,
    name: impl Into<Cow<'static, str>>,
    task: impl Future<Output = ()> + Send + 'static
)

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

fn spawn_essential_task(
    &self,
    name: impl Into<Cow<'static, str>>,
    task: impl Future<Output = ()> + 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
) -> Pin<Box<dyn Future<Output = Option<String>> + 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::Block as BlockT>::Hash>>

Get shared network instance.

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

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

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

Get shared transaction pool instance.

fn on_exit(&self) -> Exit

Deprecated:

Use spawn_task/spawn_essential_task instead, those functions will attach on_exit signal.

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

fn prometheus_registry(&self) -> Option<Registry>

Get the prometheus metrics registry, if available.

Loading content...

Implementors

impl<TBl, TBackend, TExec, TRtApi, TSc, TExPool, TOc> AbstractService for Service<TBl, Client<TBackend, TExec, TBl, TRtApi>, TSc, NetworkStatus<TBl>, NetworkService<TBl, TBl::Hash>, TExPool, TOc> where
    TBl: BlockT,
    TBackend: 'static + Backend<TBl>,
    TExec: 'static + CallExecutor<TBl> + Send + Sync + Clone,
    TRtApi: 'static + Send + Sync,
    TSc: SelectChain<TBl> + 'static + Clone + Send + Unpin,
    TExPool: 'static + TransactionPool<Block = TBl> + MallocSizeOfWasm,
    TOc: 'static + Send + Sync
[src]

type Block = TBl

type Backend = TBackend

type CallExecutor = TExec

type RuntimeApi = TRtApi

type SelectChain = TSc

type TransactionPool = TExPool

Loading content...