pub struct Relayer { /* private fields */ }Expand description
Relayer protocol handle
Implementations§
Source§impl Relayer
impl Relayer
Sourcepub fn new(chain: ChainController, shared: Arc<SyncShared>) -> Self
pub fn new(chain: ChainController, shared: Arc<SyncShared>) -> Self
Init relay protocol handle
This is a runtime relay protocol shared state, and any relay messages will be processed and forwarded by it
Get shared state
Sourcepub fn request_proposal_txs(
&self,
nc: &dyn CKBProtocolContext,
peer: PeerIndex,
block_hash_and_number: BlockNumberAndHash,
proposals: Vec<ProposalShortId>,
)
pub fn request_proposal_txs( &self, nc: &dyn CKBProtocolContext, peer: PeerIndex, block_hash_and_number: BlockNumberAndHash, proposals: Vec<ProposalShortId>, )
Request the transaction corresponding to the proposal id from the specified node
Sourcepub fn accept_block(
&self,
nc: Arc<dyn CKBProtocolContext + Sync>,
peer_id: PeerIndex,
block: BlockView,
msg_name: &str,
)
pub fn accept_block( &self, nc: Arc<dyn CKBProtocolContext + Sync>, peer_id: PeerIndex, block: BlockView, msg_name: &str, )
Accept a new block from network
Sourcepub fn reconstruct_block(
&self,
active_chain: &ActiveChain,
compact_block: &CompactBlock,
received_transactions: Vec<TransactionView>,
uncles_index: &[u32],
received_uncles: &[UncleBlockView],
) -> ReconstructionResult
pub fn reconstruct_block( &self, active_chain: &ActiveChain, compact_block: &CompactBlock, received_transactions: Vec<TransactionView>, uncles_index: &[u32], received_uncles: &[UncleBlockView], ) -> ReconstructionResult
Reorganize the full block according to the compact block/txs/uncles
Sourcepub fn ask_for_txs(&self, nc: &dyn CKBProtocolContext)
pub fn ask_for_txs(&self, nc: &dyn CKBProtocolContext)
Ask for relay transaction by hash from all peers
Sourcepub fn send_bulk_of_tx_hashes(&self, nc: &dyn CKBProtocolContext)
pub fn send_bulk_of_tx_hashes(&self, nc: &dyn CKBProtocolContext)
Send bulk of tx hashes to selected peers
Trait Implementations§
Source§impl CKBProtocolHandler for Relayer
impl CKBProtocolHandler for Relayer
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 Relayer
impl !RefUnwindSafe for Relayer
impl Send for Relayer
impl Sync for Relayer
impl Unpin for Relayer
impl !UnwindSafe for Relayer
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