Trait ckb_network::CKBProtocolContext [−][src]
pub trait CKBProtocolContext: Send {}Show 17 methods
fn set_notify(&self, interval: Duration, token: u64) -> Result<(), Error>; fn remove_notify(&self, token: u64) -> Result<(), Error>; fn quick_send_message(
&self,
proto_id: ProtocolId,
peer_index: PeerIndex,
data: Bytes
) -> Result<(), Error>; fn quick_send_message_to(
&self,
peer_index: PeerIndex,
data: Bytes
) -> Result<(), Error>; fn quick_filter_broadcast(
&self,
target: TargetSession,
data: Bytes
) -> Result<(), Error>; fn future_task(
&self,
task: Pin<Box<dyn Future<Output = ()> + Send + 'static>>,
blocking: bool
) -> Result<(), Error>; fn send_message(
&self,
proto_id: ProtocolId,
peer_index: PeerIndex,
data: Bytes
) -> Result<(), Error>; fn send_message_to(
&self,
peer_index: PeerIndex,
data: Bytes
) -> Result<(), Error>; fn filter_broadcast(
&self,
target: TargetSession,
data: Bytes
) -> Result<(), Error>; fn disconnect(
&self,
peer_index: PeerIndex,
message: &str
) -> Result<(), Error>; fn get_peer(&self, peer_index: PeerIndex) -> Option<Peer>; fn with_peer_mut(
&self,
peer_index: PeerIndex,
f: Box<dyn FnOnce(&mut Peer)>
); fn connected_peers(&self) -> Vec<PeerIndex>; fn report_peer(&self, peer_index: PeerIndex, behaviour: Behaviour); fn ban_peer(
&self,
peer_index: PeerIndex,
duration: Duration,
reason: String
); fn protocol_id(&self) -> ProtocolId; fn p2p_control(&self) -> Option<&ServiceControl> { ... }
Expand description
Abstract protocol context
Required methods
Set notify to tentacle
fn quick_send_message(
&self,
proto_id: ProtocolId,
peer_index: PeerIndex,
data: Bytes
) -> Result<(), Error>
fn quick_send_message(
&self,
proto_id: ProtocolId,
peer_index: PeerIndex,
data: Bytes
) -> Result<(), Error>
Send message through quick queue
Send message through quick queue
fn quick_filter_broadcast(
&self,
target: TargetSession,
data: Bytes
) -> Result<(), Error>
fn quick_filter_broadcast(
&self,
target: TargetSession,
data: Bytes
) -> Result<(), Error>
Filter broadcast message through quick queue
spawn a future task, if blocking is true we use tokio_threadpool::blocking to handle the task.
fn send_message(
&self,
proto_id: ProtocolId,
peer_index: PeerIndex,
data: Bytes
) -> Result<(), Error>
fn send_message(
&self,
proto_id: ProtocolId,
peer_index: PeerIndex,
data: Bytes
) -> Result<(), Error>
Send message
Send message
fn filter_broadcast(
&self,
target: TargetSession,
data: Bytes
) -> Result<(), Error>
fn filter_broadcast(
&self,
target: TargetSession,
data: Bytes
) -> Result<(), Error>
Filter broadcast message
Disconnect session
fn connected_peers(&self) -> Vec<PeerIndex>
fn connected_peers(&self) -> Vec<PeerIndex>
Get all session id
fn report_peer(&self, peer_index: PeerIndex, behaviour: Behaviour)
fn report_peer(&self, peer_index: PeerIndex, behaviour: Behaviour)
Report peer behavior
fn protocol_id(&self) -> ProtocolId
fn protocol_id(&self) -> ProtocolId
current protocol id
Provided methods
fn p2p_control(&self) -> Option<&ServiceControl>
fn p2p_control(&self) -> Option<&ServiceControl>
Raw tentacle controller