pub struct SyncingService<B: BlockT> { /* private fields */ }Expand description
Handle for communicating with SyncingEngine asynchronously
Implementations§
Source§impl<B: BlockT> SyncingService<B>
impl<B: BlockT> SyncingService<B>
Sourcepub fn new(
tx: TracingUnboundedSender<ToServiceCommand<B>>,
num_connected: Arc<AtomicUsize>,
is_major_syncing: Arc<AtomicBool>,
) -> Self
pub fn new( tx: TracingUnboundedSender<ToServiceCommand<B>>, num_connected: Arc<AtomicUsize>, is_major_syncing: Arc<AtomicBool>, ) -> Self
Create new handle
Sourcepub fn num_connected_peers(&self) -> usize
pub fn num_connected_peers(&self) -> usize
Get the number of peers known to SyncingEngine (both full and light).
Sourcepub async fn num_active_peers(&self) -> Result<usize, Canceled>
pub async fn num_active_peers(&self) -> Result<usize, Canceled>
Get the number of active peers.
Sourcepub async fn num_downloaded_blocks(&self) -> Result<usize, Canceled>
pub async fn num_downloaded_blocks(&self) -> Result<usize, Canceled>
Get the number of downloaded blocks.
Sourcepub async fn num_sync_requests(&self) -> Result<usize, Canceled>
pub async fn num_sync_requests(&self) -> Result<usize, Canceled>
Get the number of sync requests.
Sourcepub async fn peers_info(
&self,
) -> Result<Vec<(PeerId, ExtendedPeerInfo<B>)>, Canceled>
pub async fn peers_info( &self, ) -> Result<Vec<(PeerId, ExtendedPeerInfo<B>)>, Canceled>
Get peer information.
Sourcepub fn on_block_finalized(&self, hash: B::Hash, header: B::Header)
pub fn on_block_finalized(&self, hash: B::Hash, header: B::Header)
Notify the SyncingEngine that a block has been finalized.
Sourcepub fn set_no_slot_peers(&self, peers: HashSet<PeerId>)
pub fn set_no_slot_peers(&self, peers: HashSet<PeerId>)
Replace the dynamic set of no-slot peer set.
The engine maintains a per-role inbound-peer counter on top of the underlying network’s
reserved-peer handling (since https://github.com/paritytech/substrate/pull/14603) to ensure the
--in-peers budget is enforced specifically for full peers in default notification set.
A peer in either the static (config-time) or dynamic (this)
no-slot set bypasses that counter, exactly mirroring what reserved-peer handling does at
the network layer.
Each call replaces the dynamic set. The engine reconciles against its previous dynamic set.
Peers added are promoted (taken off the inbound budget). Peers removed are demoted
(counted again, or disconnected if doing so would now exceed --in-peers).
Callers that maintain a dynamic reserved-peer relationship (e.g. parachain
collator-discovery) must call this in lockstep with set_reserved_peers using the same
peer set, so the two layers stay in sync.
Sourcepub async fn status(&self) -> Result<SyncStatus<B>, Canceled>
pub async fn status(&self) -> Result<SyncStatus<B>, Canceled>
Get sync status
Returns an error if SyncingEngine has terminated.
Trait Implementations§
Source§impl<B: BlockT> JustificationSyncLink<B> for SyncingService<B>
impl<B: BlockT> JustificationSyncLink<B> for SyncingService<B>
Source§fn request_justification(&self, hash: &B::Hash, number: NumberFor<B>)
fn request_justification(&self, hash: &B::Hash, number: NumberFor<B>)
Request a justification for the given block from the network.
On success, the justification will be passed to the import queue that was part at initialization as part of the configuration.
Source§fn clear_justification_requests(&self)
fn clear_justification_requests(&self)
Source§impl<B: BlockT> Link<B> for SyncingService<B>
impl<B: BlockT> Link<B> for SyncingService<B>
Source§fn blocks_processed(
&self,
imported: usize,
count: usize,
results: Vec<(Result<BlockImportStatus<NumberFor<B>>, BlockImportError>, B::Hash)>,
)
fn blocks_processed( &self, imported: usize, count: usize, results: Vec<(Result<BlockImportStatus<NumberFor<B>>, BlockImportError>, B::Hash)>, )
Source§fn justification_imported(
&self,
who: PeerId,
hash: &B::Hash,
number: NumberFor<B>,
import_result: JustificationImportResult,
)
fn justification_imported( &self, who: PeerId, hash: &B::Hash, number: NumberFor<B>, import_result: JustificationImportResult, )
Source§fn request_justification(&self, hash: &B::Hash, number: NumberFor<B>)
fn request_justification(&self, hash: &B::Hash, number: NumberFor<B>)
Source§impl<B: BlockT> NetworkBlock<<B as Block>::Hash, <<B as Block>::Header as Header>::Number> for SyncingService<B>
impl<B: BlockT> NetworkBlock<<B as Block>::Hash, <<B as Block>::Header as Header>::Number> for SyncingService<B>
Source§impl<B: BlockT + 'static> NetworkSyncForkRequest<<B as Block>::Hash, <<B as Block>::Header as Header>::Number> for SyncingService<B>
impl<B: BlockT + 'static> NetworkSyncForkRequest<<B as Block>::Hash, <<B as Block>::Header as Header>::Number> for SyncingService<B>
Source§fn set_sync_fork_request(
&self,
peers: Vec<PeerId>,
hash: B::Hash,
number: NumberFor<B>,
)
fn set_sync_fork_request( &self, peers: Vec<PeerId>, hash: B::Hash, number: NumberFor<B>, )
Configure an explicit fork sync request.
Note that this function should not be used for recent blocks.
Sync should be able to download all the recent forks normally.
set_sync_fork_request should only be used if external code detects that there’s
a stale fork missing.
Passing empty peers set effectively removes the sync request.
Source§impl<B: BlockT> SyncEventStream for SyncingService<B>
impl<B: BlockT> SyncEventStream for SyncingService<B>
Source§impl<B: BlockT> SyncOracle for SyncingService<B>
impl<B: BlockT> SyncOracle for SyncingService<B>
Source§fn is_major_syncing(&self) -> bool
fn is_major_syncing(&self) -> bool
Source§fn is_offline(&self) -> bool
fn is_offline(&self) -> bool
Source§impl<B: BlockT> SyncStatusProvider<B> for SyncingService<B>
impl<B: BlockT> SyncStatusProvider<B> for SyncingService<B>
Auto Trait Implementations§
impl<B> Freeze for SyncingService<B>
impl<B> RefUnwindSafe for SyncingService<B>
impl<B> Send for SyncingService<B>
impl<B> Sync for SyncingService<B>
impl<B> Unpin for SyncingService<B>
impl<B> UnsafeUnpin for SyncingService<B>
impl<B> UnwindSafe for SyncingService<B>
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CheckedConversion for T
impl<T> CheckedConversion for T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<Src, Dest> IntoTuple<Dest> for Srcwhere
Dest: FromTuple<Src>,
impl<Src, Dest> IntoTuple<Dest> for Srcwhere
Dest: FromTuple<Src>,
fn into_tuple(self) -> Dest
impl<T> JsonSchemaMaybe for T
impl<T> MaybeRefUnwindSafe for Twhere
T: RefUnwindSafe,
Source§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> SaturatedConversion for T
impl<T> SaturatedConversion for T
Source§fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
Source§fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
T. Read moreSource§impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
Source§fn unchecked_into(self) -> T
fn unchecked_into(self) -> T
unchecked_from.Source§impl<T, S> UniqueSaturatedInto<T> for S
impl<T, S> UniqueSaturatedInto<T> for S
Source§fn unique_saturated_into(self) -> T
fn unique_saturated_into(self) -> T
T.