Trait ckb_network::CKBProtocolContext [−][src]
pub trait CKBProtocolContext: Send {}Show 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
fn set_notify(&self, interval: Duration, token: u64) -> Result<(), Error>[src]
fn set_notify(&self, interval: Duration, token: u64) -> Result<(), Error>[src]Set notify to tentacle
fn remove_notify(&self, token: u64) -> Result<(), Error>[src]
fn remove_notify(&self, token: u64) -> Result<(), Error>[src]Remove notify
fn quick_send_message(
&self,
proto_id: ProtocolId,
peer_index: PeerIndex,
data: Bytes
) -> Result<(), Error>[src]
fn quick_send_message(
&self,
proto_id: ProtocolId,
peer_index: PeerIndex,
data: Bytes
) -> Result<(), Error>[src]Send message through quick queue
fn quick_send_message_to(
&self,
peer_index: PeerIndex,
data: Bytes
) -> Result<(), Error>[src]
fn quick_send_message_to(
&self,
peer_index: PeerIndex,
data: Bytes
) -> Result<(), Error>[src]Send message through quick queue
fn quick_filter_broadcast(
&self,
target: TargetSession,
data: Bytes
) -> Result<(), Error>[src]
fn quick_filter_broadcast(
&self,
target: TargetSession,
data: Bytes
) -> Result<(), Error>[src]Filter broadcast message through quick queue
fn future_task(
&self,
task: Pin<Box<dyn Future<Output = ()> + Send + 'static>>,
blocking: bool
) -> Result<(), Error>[src]
fn future_task(
&self,
task: Pin<Box<dyn Future<Output = ()> + Send + 'static>>,
blocking: bool
) -> Result<(), Error>[src]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>[src]
fn send_message(
&self,
proto_id: ProtocolId,
peer_index: PeerIndex,
data: Bytes
) -> Result<(), Error>[src]Send message
fn send_message_to(
&self,
peer_index: PeerIndex,
data: Bytes
) -> Result<(), Error>[src]
fn send_message_to(
&self,
peer_index: PeerIndex,
data: Bytes
) -> Result<(), Error>[src]Send message
fn filter_broadcast(
&self,
target: TargetSession,
data: Bytes
) -> Result<(), Error>[src]
fn filter_broadcast(
&self,
target: TargetSession,
data: Bytes
) -> Result<(), Error>[src]Filter broadcast message
fn disconnect(&self, peer_index: PeerIndex, message: &str) -> Result<(), Error>[src]
fn disconnect(&self, peer_index: PeerIndex, message: &str) -> Result<(), Error>[src]Disconnect session
fn get_peer(&self, peer_index: PeerIndex) -> Option<Peer>[src]
fn get_peer(&self, peer_index: PeerIndex) -> Option<Peer>[src]Get peer info
fn with_peer_mut(&self, peer_index: PeerIndex, f: Box<dyn FnOnce(&mut Peer)>)[src]
fn with_peer_mut(&self, peer_index: PeerIndex, f: Box<dyn FnOnce(&mut Peer)>)[src]Modify peer info
fn connected_peers(&self) -> Vec<PeerIndex>[src]
fn connected_peers(&self) -> Vec<PeerIndex>[src]Get all session id
fn report_peer(&self, peer_index: PeerIndex, behaviour: Behaviour)[src]
fn report_peer(&self, peer_index: PeerIndex, behaviour: Behaviour)[src]Report peer behavior
fn ban_peer(&self, peer_index: PeerIndex, duration: Duration, reason: String)[src]
fn ban_peer(&self, peer_index: PeerIndex, duration: Duration, reason: String)[src]Ban peer
fn protocol_id(&self) -> ProtocolId[src]
fn protocol_id(&self) -> ProtocolId[src]current protocol id
Provided methods
fn p2p_control(&self) -> Option<&ServiceControl>[src]
fn p2p_control(&self) -> Option<&ServiceControl>[src]Raw tentacle controller