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: &dyn CKBProtocolContext,
peer: PeerIndex,
block: BlockView
)
pub fn accept_block( &self, nc: &dyn CKBProtocolContext, peer: PeerIndex, block: BlockView )
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 !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