[−][src]Struct sc_network::NetworkWorker
Main network worker. Must be polled in order for the network to advance.
You are encouraged to poll this in a separate background thread or task.
Implementations
impl<B: BlockT + 'static, H: ExHashT> NetworkWorker<B, H>
[src]
pub fn new(params: Params<B, H>) -> Result<NetworkWorker<B, H>, Error>
[src]
Creates the network service.
Returns a NetworkWorker
that implements Future
and must be regularly polled in order
for the network processing to advance. From it, you can extract a NetworkService
using
worker.service()
. The NetworkService
can be shared through the codebase.
pub fn average_download_per_sec(&self) -> u64
[src]
Returns the downloaded bytes per second averaged over the past few seconds.
pub fn average_upload_per_sec(&self) -> u64
[src]
Returns the uploaded bytes per second averaged over the past few seconds.
pub fn num_connected_peers(&self) -> usize
[src]
Returns the number of peers we're connected to.
pub fn num_active_peers(&self) -> usize
[src]
Returns the number of peers we're connected to and that are being queried.
pub fn sync_state(&self) -> SyncState
[src]
Current global sync state.
pub fn best_seen_block(&self) -> Option<NumberFor<B>>
[src]
Target sync block number.
pub fn num_sync_peers(&self) -> u32
[src]
Number of peers participating in syncing.
pub fn num_queued_blocks(&self) -> u32
[src]
Number of blocks in the import queue.
pub fn num_downloaded_blocks(&self) -> usize
[src]
Returns the number of downloaded blocks.
pub fn num_sync_requests(&self) -> usize
[src]
Number of active sync requests.
pub fn add_known_address(&mut self, peer_id: PeerId, addr: Multiaddr)
[src]
Adds an address for a node.
pub fn service(&self) -> &Arc<NetworkService<B, H>>
[src]
Return a NetworkService
that can be shared through the code base and can be used to
manipulate the worker.
pub fn on_block_finalized(&mut self, hash: B::Hash, header: B::Header)
[src]
You must call this when a new block is finalized by the client.
pub fn update_chain(&mut self)
[src]
This should be called when blocks are added to the chain by something other than the import queue. Currently this is only useful for tests.
pub fn local_peer_id(&self) -> &PeerId
[src]
Returns the local PeerId
.
pub fn listen_addresses(&self) -> impl Iterator<Item = &Multiaddr>
[src]
Returns the list of addresses we are listening on.
Does NOT include a trailing /p2p/
with our PeerId
.
pub fn network_state(&mut self) -> NetworkState
[src]
Get network state.
Note: Use this only for debugging. This API is unstable. There are warnings literally everywhere about this. Please don't use this function to retrieve actual information.
pub fn peers_debug_info(&mut self) -> Vec<(PeerId, PeerInfo<B>)>
[src]
Get currently connected peers.
pub fn remove_reserved_peer(&self, peer: PeerId)
[src]
Removes a PeerId
from the list of reserved peers.
pub fn add_reserved_peer(&self, peer: String) -> Result<(), String>
[src]
Adds a PeerId
and its address as reserved. The string should encode the address
and peer ID of the remote node.
Trait Implementations
impl<B: BlockT + 'static, H: ExHashT> Future for NetworkWorker<B, H>
[src]
type Output = Result<(), Error>
The type of value produced on completion.
fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output>
[src]
impl<B: BlockT + 'static, H: ExHashT> Unpin for NetworkWorker<B, H>
[src]
Auto Trait Implementations
impl<B, H> !RefUnwindSafe for NetworkWorker<B, H>
impl<B, H> Send for NetworkWorker<B, H> where
<B as Block>::Extrinsic: Send,
<B as Block>::Hash: Send,
<B as Block>::Header: Header + Send,
<<B as Block>::Header as Header>::Number: Send,
<B as Block>::Extrinsic: Send,
<B as Block>::Hash: Send,
<B as Block>::Header: Header + Send,
<<B as Block>::Header as Header>::Number: Send,
impl<B, H> !Sync for NetworkWorker<B, H>
impl<B, H> !UnwindSafe for NetworkWorker<B, H>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> CheckedConversion for T
[src]
fn checked_from<T>(t: T) -> Option<Self> where
Self: TryFrom<T>,
[src]
Self: TryFrom<T>,
fn checked_into<T>(self) -> Option<T> where
Self: TryInto<T>,
[src]
Self: TryInto<T>,
impl<T> From<T> for T
[src]
impl<T> FutureExt for T where
T: Future + ?Sized,
[src]
T: Future + ?Sized,
fn map<U, F>(self, f: F) -> Map<Self, F> where
F: FnOnce(Self::Output) -> U,
[src]
F: FnOnce(Self::Output) -> U,
fn map_into<U>(self) -> MapInto<Self, U> where
Self::Output: Into<U>,
[src]
Self::Output: Into<U>,
fn then<Fut, F>(self, f: F) -> Then<Self, Fut, F> where
F: FnOnce(Self::Output) -> Fut,
Fut: Future,
[src]
F: FnOnce(Self::Output) -> Fut,
Fut: Future,
fn left_future<B>(self) -> Either<Self, B> where
B: Future<Output = Self::Output>,
[src]
B: Future<Output = Self::Output>,
fn right_future<A>(self) -> Either<A, Self> where
A: Future<Output = Self::Output>,
[src]
A: Future<Output = Self::Output>,
fn into_stream(self) -> IntoStream<Self>
[src]
fn flatten(self) -> Flatten<Self> where
Self::Output: Future,
[src]
Self::Output: Future,
fn flatten_stream(self) -> FlattenStream<Self> where
Self::Output: Stream,
[src]
Self::Output: Stream,
fn fuse(self) -> Fuse<Self>
[src]
fn inspect<F>(self, f: F) -> Inspect<Self, F> where
F: FnOnce(&Self::Output),
[src]
F: FnOnce(&Self::Output),
fn catch_unwind(self) -> CatchUnwind<Self> where
Self: UnwindSafe,
[src]
Self: UnwindSafe,
fn shared(self) -> Shared<Self> where
Self::Output: Clone,
[src]
Self::Output: Clone,
fn remote_handle(self) -> (Remote<Self>, RemoteHandle<Self::Output>)
[src]
fn boxed<'a>(self) -> Pin<Box<dyn Future<Output = Self::Output> + 'a + Send>> where
Self: Send + 'a,
[src]
Self: Send + 'a,
fn boxed_local<'a>(self) -> Pin<Box<dyn Future<Output = Self::Output> + 'a>> where
Self: 'a,
[src]
Self: 'a,
fn unit_error(self) -> UnitError<Self>
[src]
fn never_error(self) -> NeverError<Self>
[src]
fn poll_unpin(&mut self, cx: &mut Context) -> Poll<Self::Output> where
Self: Unpin,
[src]
Self: Unpin,
fn now_or_never(self) -> Option<Self::Output>
[src]
impl<T> FutureExt for T where
T: Future + ?Sized,
T: Future + ?Sized,
fn delay(self, dur: Duration) -> DelayFuture<Self>
fn flatten(self) -> FlattenFuture<Self, <Self::Output as IntoFuture>::Future> where
Self::Output: IntoFuture,
Self::Output: IntoFuture,
fn race<F>(self, other: F) -> Race<Self, F> where
F: Future<Output = Self::Output>,
Self: Future,
F: Future<Output = Self::Output>,
Self: Future,
fn try_race<F, T, E>(self, other: F) -> TryRace<Self, F> where
F: Future<Output = Self::Output>,
Self: Future<Output = Result<T, E>>,
F: Future<Output = Self::Output>,
Self: Future<Output = Result<T, E>>,
fn join<F>(self, other: F) -> Join<Self, F> where
F: Future,
Self: Future,
F: Future,
Self: Future,
fn try_join<F, A, B, E>(self, other: F) -> TryJoin<Self, F> where
F: Future<Output = Result<B, E>>,
Self: Future<Output = Result<A, E>>,
F: Future<Output = Result<B, E>>,
Self: Future<Output = Result<A, E>>,
fn timeout(self, dur: Duration) -> TimeoutFuture<Self>
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<F> IntoFuture for F where
F: Future,
[src]
F: Future,
type Output = <F as Future>::Output
into_future
)The output that the future will produce on completion.
type Future = F
into_future
)Which kind of future are we turning this into?
fn into_future(self) -> <F as IntoFuture>::Future
[src]
impl<T> IntoFuture for T where
T: Future,
T: Future,
type Output = <T as Future>::Output
The type of value produced on completion.
type Future = T
Which kind of future are we turning this into?
fn into_future(self) -> <T as IntoFuture>::Future
impl<T, Outer> IsWrappedBy<Outer> for T where
Outer: AsRef<T> + AsMut<T> + From<T>,
T: From<Outer>,
[src]
Outer: AsRef<T> + AsMut<T> + From<T>,
T: From<Outer>,
fn from_ref(outer: &Outer) -> &T
[src]
Get a reference to the inner from the outer.
fn from_mut(outer: &mut Outer) -> &mut T
[src]
Get a mutable reference to the inner from the outer.
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> SaturatedConversion for T
[src]
fn saturated_from<T>(t: T) -> Self where
Self: UniqueSaturatedFrom<T>,
[src]
Self: UniqueSaturatedFrom<T>,
fn saturated_into<T>(self) -> T where
Self: UniqueSaturatedInto<T>,
[src]
Self: UniqueSaturatedInto<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<F, T, E> TryFuture for F where
F: Future<Output = Result<T, E>> + ?Sized,
[src]
F: Future<Output = Result<T, E>> + ?Sized,
type Ok = T
The type of successful values yielded by this future
type Error = E
The type of failures yielded by this future
fn try_poll(self: Pin<&mut F>, cx: &mut Context) -> Poll<<F as Future>::Output>
[src]
impl<Fut> TryFutureExt for Fut where
Fut: TryFuture + ?Sized,
[src]
Fut: TryFuture + ?Sized,
fn flatten_sink<Item>(self) -> FlattenSink<Self, Self::Ok> where
Self::Ok: Sink<Item>,
<Self::Ok as Sink<Item>>::Error == Self::Error,
[src]
Self::Ok: Sink<Item>,
<Self::Ok as Sink<Item>>::Error == Self::Error,
fn map_ok<T, F>(self, f: F) -> MapOk<Self, F> where
F: FnOnce(Self::Ok) -> T,
[src]
F: FnOnce(Self::Ok) -> T,
fn map_ok_or_else<T, E, F>(self, e: E, f: F) -> MapOkOrElse<Self, F, E> where
E: FnOnce(Self::Error) -> T,
F: FnOnce(Self::Ok) -> T,
[src]
E: FnOnce(Self::Error) -> T,
F: FnOnce(Self::Ok) -> T,
fn map_err<E, F>(self, f: F) -> MapErr<Self, F> where
F: FnOnce(Self::Error) -> E,
[src]
F: FnOnce(Self::Error) -> E,
fn err_into<E>(self) -> ErrInto<Self, E> where
Self::Error: Into<E>,
[src]
Self::Error: Into<E>,
fn ok_into<U>(self) -> OkInto<Self, U> where
Self::Ok: Into<U>,
[src]
Self::Ok: Into<U>,
fn and_then<Fut, F>(self, f: F) -> AndThen<Self, Fut, F> where
F: FnOnce(Self::Ok) -> Fut,
Fut: TryFuture<Error = Self::Error>,
[src]
F: FnOnce(Self::Ok) -> Fut,
Fut: TryFuture<Error = Self::Error>,
fn or_else<Fut, F>(self, f: F) -> OrElse<Self, Fut, F> where
F: FnOnce(Self::Error) -> Fut,
Fut: TryFuture<Ok = Self::Ok>,
[src]
F: FnOnce(Self::Error) -> Fut,
Fut: TryFuture<Ok = Self::Ok>,
fn inspect_ok<F>(self, f: F) -> InspectOk<Self, F> where
F: FnOnce(&Self::Ok),
[src]
F: FnOnce(&Self::Ok),
fn inspect_err<F>(self, f: F) -> InspectErr<Self, F> where
F: FnOnce(&Self::Error),
[src]
F: FnOnce(&Self::Error),
fn try_flatten(self) -> TryFlatten<Self, Self::Ok> where
Self::Ok: TryFuture,
<Self::Ok as TryFuture>::Error == Self::Error,
[src]
Self::Ok: TryFuture,
<Self::Ok as TryFuture>::Error == Self::Error,
fn try_flatten_stream(self) -> TryFlattenStream<Self> where
Self::Ok: TryStream,
<Self::Ok as TryStream>::Error == Self::Error,
[src]
Self::Ok: TryStream,
<Self::Ok as TryStream>::Error == Self::Error,
fn unwrap_or_else<F>(self, f: F) -> UnwrapOrElse<Self, F> where
F: FnOnce(Self::Error) -> Self::Ok,
[src]
F: FnOnce(Self::Error) -> Self::Ok,
fn into_future(self) -> IntoFuture<Self>
[src]
fn try_poll_unpin(
&mut self,
cx: &mut Context
) -> Poll<Result<Self::Ok, Self::Error>> where
Self: Unpin,
[src]
&mut self,
cx: &mut Context
) -> Poll<Result<Self::Ok, Self::Error>> where
Self: Unpin,
impl<F> TryFutureExt for F where
F: TryFuture,
[src]
F: TryFuture,
fn timeout(self, dur: Duration) -> Timeout<Self> where
Self::Error: From<Error>,
[src]
Self::Error: From<Error>,
fn timeout_at(self, at: Instant) -> Timeout<Self> where
Self::Error: From<Error>,
[src]
Self::Error: From<Error>,
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<S, T> UncheckedInto<T> for S where
T: UncheckedFrom<S>,
[src]
T: UncheckedFrom<S>,
fn unchecked_into(self) -> T
[src]
impl<T, S> UniqueSaturatedInto<T> for S where
S: TryInto<T>,
T: Bounded,
[src]
S: TryInto<T>,
T: Bounded,
fn unique_saturated_into(self) -> T
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,