pub struct StateStrategy<B: BlockT> { /* private fields */ }
Expand description
Syncing strategy that downloads and imports a recent state directly.
Implementations§
Source§impl<B: BlockT> StateStrategy<B>
impl<B: BlockT> StateStrategy<B>
Sourcepub const STRATEGY_KEY: StrategyKey
pub const STRATEGY_KEY: StrategyKey
Strategy key used by state sync.
Sourcepub fn new<Client>(
client: Arc<Client>,
target_header: B::Header,
target_body: Option<Vec<B::Extrinsic>>,
target_justifications: Option<Justifications>,
skip_proof: bool,
initial_peers: impl Iterator<Item = (PeerId, NumberFor<B>)>,
protocol_name: ProtocolName,
) -> Self
pub fn new<Client>( client: Arc<Client>, target_header: B::Header, target_body: Option<Vec<B::Extrinsic>>, target_justifications: Option<Justifications>, skip_proof: bool, initial_peers: impl Iterator<Item = (PeerId, NumberFor<B>)>, protocol_name: ProtocolName, ) -> Self
Create a new instance.
Sourcepub fn new_with_provider(
state_sync_provider: Box<dyn StateSyncProvider<B>>,
initial_peers: impl Iterator<Item = (PeerId, NumberFor<B>)>,
protocol_name: ProtocolName,
) -> Self
pub fn new_with_provider( state_sync_provider: Box<dyn StateSyncProvider<B>>, initial_peers: impl Iterator<Item = (PeerId, NumberFor<B>)>, protocol_name: ProtocolName, ) -> Self
Create a new instance with a custom state sync provider.
Note: In most cases, users should use StateStrategy::new
.
This method is intended for custom sync strategies and advanced use cases.
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.
Sourcepub fn on_state_response(&mut self, peer_id: &PeerId, response: Vec<u8>)
pub fn on_state_response(&mut self, peer_id: &PeerId, response: Vec<u8>)
Process state response.
Sourcepub fn on_blocks_processed(
&mut self,
imported: usize,
count: usize,
results: Vec<(Result<BlockImportStatus<NumberFor<B>>, BlockImportError>, B::Hash)>,
)
pub fn on_blocks_processed( &mut self, imported: usize, count: usize, results: Vec<(Result<BlockImportStatus<NumberFor<B>>, BlockImportError>, B::Hash)>, )
A batch of blocks have been processed, with or without errors.
Normally this should be called when target block with state is imported.
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.
Sourcepub fn is_succeeded(&self) -> bool
pub fn is_succeeded(&self) -> bool
Check if state sync has succeeded.
Auto Trait Implementations§
impl<B> Freeze for StateStrategy<B>
impl<B> !RefUnwindSafe for StateStrategy<B>
impl<B> Send for StateStrategy<B>
impl<B> !Sync for StateStrategy<B>
impl<B> Unpin for StateStrategy<B>
impl<B> !UnwindSafe for StateStrategy<B>
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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>,
Consume self to return an equivalent value of
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
The counterpart to
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
Consume self to return an equivalent value of
T
.