pub struct WarpSync<B: BlockT, Client> { /* private fields */ }
Expand description
Warp sync state machine. Accumulates warp proofs and state.
Implementations§
Source§impl<B, Client> WarpSync<B, Client>where
B: BlockT,
Client: HeaderBackend<B> + 'static,
impl<B, Client> WarpSync<B, Client>where
B: BlockT,
Client: HeaderBackend<B> + 'static,
Sourcepub const STRATEGY_KEY: StrategyKey
pub const STRATEGY_KEY: StrategyKey
Strategy key used by warp sync.
Sourcepub fn new(
client: Arc<Client>,
warp_sync_config: WarpSyncConfig<B>,
protocol_name: Option<ProtocolName>,
block_downloader: Arc<dyn BlockDownloader<B>>,
) -> Self
pub fn new( client: Arc<Client>, warp_sync_config: WarpSyncConfig<B>, protocol_name: Option<ProtocolName>, block_downloader: Arc<dyn BlockDownloader<B>>, ) -> Self
Create a new instance. When passing a warp sync provider we will be checking for proof and authorities. Alternatively we can pass a target block when we want to skip downloading proofs, in this case we will continue polling until the target block is known.
Sourcepub fn add_peer(
&mut self,
peer_id: PeerId,
_best_hash: B::Hash,
best_number: NumberFor<B>,
)
pub fn add_peer( &mut self, peer_id: PeerId, _best_hash: B::Hash, best_number: NumberFor<B>, )
Notify that a new peer has connected.
Sourcepub fn remove_peer(&mut self, peer_id: &PeerId)
pub fn remove_peer(&mut self, peer_id: &PeerId)
Notify that a peer has disconnected.
Sourcepub fn on_validated_block_announce(
&mut self,
is_best: bool,
peer_id: PeerId,
announce: &BlockAnnounce<B::Header>,
) -> Option<(B::Hash, NumberFor<B>)>
pub fn on_validated_block_announce( &mut self, is_best: bool, peer_id: PeerId, announce: &BlockAnnounce<B::Header>, ) -> Option<(B::Hash, NumberFor<B>)>
Submit a validated block announcement.
Returns new best hash & best number of the peer if they are updated.
pub fn on_generic_response( &mut self, peer_id: &PeerId, protocol_name: ProtocolName, response: Box<dyn Any + Send>, )
Sourcepub fn on_warp_proof_response(
&mut self,
peer_id: &PeerId,
response: EncodedProof,
)
pub fn on_warp_proof_response( &mut self, peer_id: &PeerId, response: EncodedProof, )
Process warp proof response.
Sourcepub fn on_block_response(
&mut self,
peer_id: PeerId,
request: BlockRequest<B>,
blocks: Vec<BlockData<B>>,
)
pub fn on_block_response( &mut self, peer_id: PeerId, request: BlockRequest<B>, blocks: Vec<BlockData<B>>, )
Process (target) block response.
Sourcepub fn progress(&self) -> WarpSyncProgress<B>
pub fn progress(&self) -> WarpSyncProgress<B>
Returns warp sync estimated progress (stage, bytes received).
Sourcepub fn status(&self) -> SyncStatus<B>
pub fn status(&self) -> SyncStatus<B>
Returns the current sync status.
Sourcepub fn actions(
&mut self,
network_service: &NetworkServiceHandle,
) -> impl Iterator<Item = SyncingAction<B>>
pub fn actions( &mut self, network_service: &NetworkServiceHandle, ) -> impl Iterator<Item = SyncingAction<B>>
Get actions that should be performed by the owner on WarpSync
’s behalf
Sourcepub fn take_result(&mut self) -> Option<WarpSyncResult<B>>
pub fn take_result(&mut self) -> Option<WarpSyncResult<B>>
Take the result of finished warp sync, returning None
if the sync was unsuccessful.
Auto Trait Implementations§
impl<B, Client> Freeze for WarpSync<B, Client>
impl<B, Client> !RefUnwindSafe for WarpSync<B, Client>
impl<B, Client> Send for WarpSync<B, Client>
impl<B, Client> !Sync for WarpSync<B, Client>
impl<B, Client> Unpin for WarpSync<B, Client>
impl<B, Client> !UnwindSafe for WarpSync<B, Client>
Blanket Implementations§
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
Source§impl<T> CheckedConversion for T
impl<T> CheckedConversion for T
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
Source§impl<T, Outer> IsWrappedBy<Outer> for T
impl<T, Outer> IsWrappedBy<Outer> for T
Source§impl<T> Pointable for T
impl<T> Pointable for T
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
.