pub struct Synchronizer {
pub shared: Arc<SyncShared>,
/* private fields */
}
Expand description
Sync protocol handle
Fields§
Sync shared state
Implementations§
Source§impl Synchronizer
impl Synchronizer
Sourcepub fn new(chain: ChainController, shared: Arc<SyncShared>) -> Synchronizer
pub fn new(chain: ChainController, shared: Arc<SyncShared>) -> Synchronizer
Init sync protocol handle
This is a runtime sync protocol shared state, and any Sync protocol messages will be processed and forwarded by it
Get shared state
Sourcepub fn asynchronous_process_remote_block(&self, remote_block: RemoteBlock)
pub fn asynchronous_process_remote_block(&self, remote_block: RemoteBlock)
Process a new block sync from other peer
Sourcepub fn get_blocks_to_fetch(
&self,
peer: PeerIndex,
ibd: IBDState,
) -> Option<Vec<Vec<Byte32>>>
pub fn get_blocks_to_fetch( &self, peer: PeerIndex, ibd: IBDState, ) -> Option<Vec<Vec<Byte32>>>
Get blocks to fetch
Sourcepub fn eviction(&self, nc: &dyn CKBProtocolContext)
pub fn eviction(&self, nc: &dyn CKBProtocolContext)
Regularly check and eject some nodes that do not respond in time
Trait Implementations§
Source§impl CKBProtocolHandler for Synchronizer
impl CKBProtocolHandler for Synchronizer
Source§fn init<'life0, 'async_trait>(
&'life0 mut self,
nc: Arc<dyn CKBProtocolContext + Sync>,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn init<'life0, 'async_trait>(
&'life0 mut self,
nc: Arc<dyn CKBProtocolContext + Sync>,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Init action on service run
Source§fn received<'life0, 'async_trait>(
&'life0 mut self,
nc: Arc<dyn CKBProtocolContext + Sync>,
peer_index: PeerIndex,
data: Bytes,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn received<'life0, 'async_trait>(
&'life0 mut self,
nc: Arc<dyn CKBProtocolContext + Sync>,
peer_index: PeerIndex,
data: Bytes,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Called when the corresponding protocol message is received
Source§fn connected<'life0, 'life1, 'async_trait>(
&'life0 mut self,
nc: Arc<dyn CKBProtocolContext + Sync>,
peer_index: PeerIndex,
_version: &'life1 str,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn connected<'life0, 'life1, 'async_trait>(
&'life0 mut self,
nc: Arc<dyn CKBProtocolContext + Sync>,
peer_index: PeerIndex,
_version: &'life1 str,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Called when opening protocol
Source§fn disconnected<'life0, 'async_trait>(
&'life0 mut self,
_nc: Arc<dyn CKBProtocolContext + Sync>,
peer_index: PeerIndex,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn disconnected<'life0, 'async_trait>(
&'life0 mut self,
_nc: Arc<dyn CKBProtocolContext + Sync>,
peer_index: PeerIndex,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Called when closing protocol
Auto Trait Implementations§
impl Freeze for Synchronizer
impl !RefUnwindSafe for Synchronizer
impl Send for Synchronizer
impl Sync for Synchronizer
impl Unpin for Synchronizer
impl !UnwindSafe for Synchronizer
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> 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 more