Struct ckb_network::network::NetworkController
source · pub struct NetworkController { /* private fields */ }Expand description
Network controller
Implementations§
source§impl NetworkController
impl NetworkController
sourcepub fn p2p_control(&self) -> &ServiceControl
pub fn p2p_control(&self) -> &ServiceControl
p2p service control
sourcepub fn remove_node(&self, peer_id: &PeerId)
pub fn remove_node(&self, peer_id: &PeerId)
Disconnect session with peer id
sourcepub fn get_banned_addrs(&self) -> Vec<BannedAddr> ⓘ
pub fn get_banned_addrs(&self) -> Vec<BannedAddr> ⓘ
Get banned peer list
sourcepub fn clear_banned_addrs(&self)
pub fn clear_banned_addrs(&self)
Clear banned list
sourcepub fn connected_peers(&self) -> Vec<(PeerIndex, Peer)> ⓘ
pub fn connected_peers(&self) -> Vec<(PeerIndex, Peer)> ⓘ
Return all connected peers’ information
sourcepub fn ban_peer(&self, peer_index: PeerIndex, duration: Duration, reason: String)
pub fn ban_peer(&self, peer_index: PeerIndex, duration: Duration, reason: String)
Ban an peer through peer index
sourcepub fn broadcast(
&self,
proto_id: ProtocolId,
data: Bytes
) -> Result<(), SendErrorKind>
pub fn broadcast(
&self,
proto_id: ProtocolId,
data: Bytes
) -> Result<(), SendErrorKind>
Broadcast a message to all connected peers
sourcepub fn quick_broadcast(
&self,
proto_id: ProtocolId,
data: Bytes
) -> Result<(), SendErrorKind>
pub fn quick_broadcast(
&self,
proto_id: ProtocolId,
data: Bytes
) -> Result<(), SendErrorKind>
Broadcast a message to all connected peers through quick queue
sourcepub fn send_message_to(
&self,
session_id: SessionId,
proto_id: ProtocolId,
data: Bytes
) -> Result<(), SendErrorKind>
pub fn send_message_to(
&self,
session_id: SessionId,
proto_id: ProtocolId,
data: Bytes
) -> Result<(), SendErrorKind>
Send message to one connected peer
sourcepub fn is_active(&self) -> bool
pub fn is_active(&self) -> bool
network message processing controller, always true, if false, discard any received messages
sourcepub fn set_active(&self, active: bool)
pub fn set_active(&self, active: bool)
Change active status, if set false discard any received messages
sourcepub fn protocols(&self) -> Vec<(ProtocolId, String, Vec<String>)> ⓘ
pub fn protocols(&self) -> Vec<(ProtocolId, String, Vec<String>)> ⓘ
Return all connected peers’ protocols info
sourcepub fn ping_peers(&self)
pub fn ping_peers(&self)
Try ping all connected peers
sourcepub fn non_owning_clone(&self) -> Self
pub fn non_owning_clone(&self) -> Self
Since a non-owning reference does not count towards ownership, it will not prevent the value stored in the allocation from being dropped
Trait Implementations§
source§impl Clone for NetworkController
impl Clone for NetworkController
source§fn clone(&self) -> NetworkController
fn clone(&self) -> NetworkController
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read more