pub enum SyncingStrategy<B: BlockT, Client> {
    WarpSyncStrategy(WarpSync<B, Client>),
    StateSyncStrategy(StateStrategy<B>),
    ChainSyncStrategy(ChainSync<B, Client>),
}
Expand description

Proxy to specific syncing strategies.

Variants§

§

WarpSyncStrategy(WarpSync<B, Client>)

§

StateSyncStrategy(StateStrategy<B>)

§

ChainSyncStrategy(ChainSync<B, Client>)

Implementations§

source§

impl<B, Client> SyncingStrategy<B, Client>
where B: BlockT, Client: HeaderBackend<B> + BlockBackend<B> + HeaderMetadata<B, Error = Error> + ProofProvider<B> + Send + Sync + 'static,

source

pub fn new( config: SyncingConfig, client: Arc<Client>, warp_sync_config: Option<WarpSyncConfig<B>> ) -> Result<Self, ClientError>

Initialize a new syncing startegy.

source

pub fn add_peer( &mut self, peer_id: PeerId, best_hash: B::Hash, best_number: NumberFor<B> )

Notify that a new peer has connected.

source

pub fn remove_peer(&mut self, peer_id: &PeerId)

Notify that a peer has disconnected.

source

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.

source

pub fn set_sync_fork_request( &mut self, peers: Vec<PeerId>, hash: &B::Hash, number: NumberFor<B> )

Configure an explicit fork sync request in case external code has detected that there is a stale fork missing.

source

pub fn request_justification(&mut self, hash: &B::Hash, number: NumberFor<B>)

Request extra justification.

source

pub fn clear_justification_requests(&mut self)

Clear extra justification requests.

source

pub fn on_justification_import( &mut self, hash: B::Hash, number: NumberFor<B>, success: bool )

Report a justification import (successful or not).

source

pub fn on_block_response( &mut self, peer_id: PeerId, request: BlockRequest<B>, blocks: Vec<BlockData<B>> )

Process block response.

source

pub fn on_state_response( &mut self, peer_id: PeerId, response: OpaqueStateResponse )

Process state response.

source

pub fn on_warp_proof_response( &mut self, peer_id: &PeerId, response: EncodedProof )

Process warp proof response.

source

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.

source

pub fn on_block_finalized(&mut self, hash: &B::Hash, number: NumberFor<B>)

Notify a syncing strategy that a block has been finalized.

source

pub fn update_chain_info( &mut self, best_hash: &B::Hash, best_number: NumberFor<B> )

Inform sync about a new best imported block.

source

pub fn is_major_syncing(&self) -> bool

source

pub fn num_peers(&self) -> usize

Get the number of peers known to the syncing strategy.

source

pub fn status(&self) -> SyncStatus<B>

Returns the current sync status.

source

pub fn num_downloaded_blocks(&self) -> usize

Get the total number of downloaded blocks.

source

pub fn num_sync_requests(&self) -> usize

Get an estimate of the number of parallel sync requests.

source

pub fn report_metrics(&self)

Report Prometheus metrics

source

pub fn actions(&mut self) -> Box<dyn Iterator<Item = SyncingAction<B>>>

Get actions that should be performed by the owner on the strategy’s behalf

source

pub fn switch_to_next( &mut self, config: SyncingConfig, client: Arc<Client>, connected_peers: impl Iterator<Item = (PeerId, B::Hash, NumberFor<B>)> ) -> Result<(), ClientError>

Switch to next strategy if the active one finished.

Auto Trait Implementations§

§

impl<B, Client> !RefUnwindSafe for SyncingStrategy<B, Client>

§

impl<B, Client> Send for SyncingStrategy<B, Client>
where Client: Sync + Send,

§

impl<B, Client> !Sync for SyncingStrategy<B, Client>

§

impl<B, Client> Unpin for SyncingStrategy<B, Client>
where <B as Block>::Extrinsic: Unpin, <B as Block>::Hash: Unpin, <B as Block>::Header: Unpin, <<B as Block>::Header as Header>::Number: Unpin,

§

impl<B, Client> !UnwindSafe for SyncingStrategy<B, Client>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Any for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

§

fn type_name(&self) -> &'static str

source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CheckedConversion for T

source§

fn checked_from<T>(t: T) -> Option<Self>
where Self: TryFrom<T>,

Convert from a value of T into an equivalent instance of Option<Self>. Read more
source§

fn checked_into<T>(self) -> Option<T>
where Self: TryInto<T>,

Consume self to return Some equivalent value of Option<T>. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, Outer> IsWrappedBy<Outer> for T
where Outer: AsRef<T> + AsMut<T> + From<T>, T: From<Outer>,

source§

fn from_ref(outer: &Outer) -> &T

Get a reference to the inner from the outer.

source§

fn from_mut(outer: &mut Outer) -> &mut T

Get a mutable reference to the inner from the outer.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> SaturatedConversion for T

source§

fn saturated_from<T>(t: T) -> Self
where Self: UniqueSaturatedFrom<T>,

Convert from a value of T into an equivalent instance of Self. Read more
source§

fn saturated_into<T>(self) -> T
where Self: UniqueSaturatedInto<T>,

Consume self to return an equivalent value of T. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<S, T> UncheckedInto<T> for S
where T: UncheckedFrom<S>,

source§

fn unchecked_into(self) -> T

The counterpart to unchecked_from.
source§

impl<T, S> UniqueSaturatedInto<T> for S
where T: Bounded, S: TryInto<T>,

source§

fn unique_saturated_into(self) -> T

Consume self to return an equivalent value of T.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> JsonSchemaMaybe for T