pub struct SyncManager { /* private fields */ }Expand description
Sync manager coordinates chain synchronization.
Implementations§
Source§impl SyncManager
impl SyncManager
Sourcepub fn new(config: SyncConfig) -> Self
pub fn new(config: SyncConfig) -> Self
Create a new sync manager.
Sourcepub fn config(&self) -> &SyncConfig
pub fn config(&self) -> &SyncConfig
Get the configuration.
Sourcepub async fn status(&self) -> SyncStatus
pub async fn status(&self) -> SyncStatus
Get the current sync status.
Sourcepub async fn needs_sync(&self, local_height: Option<u64>) -> bool
pub async fn needs_sync(&self, local_height: Option<u64>) -> bool
Check if we need to sync.
Sourcepub async fn update_peer_height(&self, peer: PeerId, height: u64)
pub async fn update_peer_height(&self, peer: PeerId, height: u64)
Update a peer’s reported height.
Sourcepub async fn remove_peer(&self, peer: &PeerId)
pub async fn remove_peer(&self, peer: &PeerId)
Remove a peer (on disconnect).
Sourcepub async fn start_sync(&self, from_height: u64, to_height: u64)
pub async fn start_sync(&self, from_height: u64, to_height: u64)
Start syncing from a specific height.
Sourcepub async fn pause_sync(&self)
pub async fn pause_sync(&self)
Pause syncing.
Sourcepub async fn resume_sync(&self)
pub async fn resume_sync(&self)
Resume syncing.
Sourcepub async fn next_request(
&self,
available_peers: &[PeerInfo],
) -> Option<(PeerId, Message)>
pub async fn next_request( &self, available_peers: &[PeerInfo], ) -> Option<(PeerId, Message)>
Get the next sync request to send.
Returns (peer_id, message) if there’s work to do.
Sourcepub async fn handle_blocks(
&self,
response: BlocksMessage,
) -> Result<Vec<Block>, SyncError>
pub async fn handle_blocks( &self, response: BlocksMessage, ) -> Result<Vec<Block>, SyncError>
Handle a received blocks response.
Sourcepub async fn handle_headers(
&self,
response: HeadersMessage,
) -> Result<Vec<BlockHeader>, SyncError>
pub async fn handle_headers( &self, response: HeadersMessage, ) -> Result<Vec<BlockHeader>, SyncError>
Handle a received headers response.
Sourcepub async fn handle_snapshot(
&self,
response: SnapshotMessage,
) -> Result<(), SyncError>
pub async fn handle_snapshot( &self, response: SnapshotMessage, ) -> Result<(), SyncError>
Handle a received snapshot response.
Sourcepub async fn get_ready_blocks(&self, current_height: u64) -> Vec<Block>
pub async fn get_ready_blocks(&self, current_height: u64) -> Vec<Block>
Get blocks ready to apply (in order).
Sourcepub async fn complete_range(&self, start: u64, end: u64)
pub async fn complete_range(&self, start: u64, end: u64)
Mark a range as complete.
Sourcepub async fn handle_timeout(&self, request_id: MessageId)
pub async fn handle_timeout(&self, request_id: MessageId)
Handle a request timeout.
Sourcepub async fn get_timed_out_requests(&self) -> Vec<MessageId> ⓘ
pub async fn get_timed_out_requests(&self) -> Vec<MessageId> ⓘ
Get timed out requests.
Sourcepub fn create_snapshot_request(
&self,
height: Option<u64>,
) -> (MessageId, Message)
pub fn create_snapshot_request( &self, height: Option<u64>, ) -> (MessageId, Message)
Request a snapshot from a peer.
Sourcepub fn create_blocks_request(
&self,
start: u64,
count: u32,
) -> (MessageId, Message)
pub fn create_blocks_request( &self, start: u64, count: u32, ) -> (MessageId, Message)
Request blocks from a peer.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for SyncManager
impl !RefUnwindSafe for SyncManager
impl Send for SyncManager
impl Sync for SyncManager
impl Unpin for SyncManager
impl !UnwindSafe for SyncManager
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
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> 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<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Returns the layout of the type.
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Returns whether the given value has been niched. Read more
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
Writes data to
out indicating that a T is niched.