Struct ckb_network::network::NetworkController
source · pub struct NetworkController { /* private fields */ }Expand description
Network controller
Implementations§
source§impl NetworkController
impl NetworkController
sourcepub fn init_ckb2023(&self)
pub fn init_ckb2023(&self)
Set ckb2023 start
sourcepub fn load_ckb2023(&self) -> bool
pub fn load_ckb2023(&self) -> bool
Get ckb2023 flag
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
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 moreAuto Trait Implementations§
impl !RefUnwindSafe for NetworkController
impl Send for NetworkController
impl Sync for NetworkController
impl Unpin for NetworkController
impl !UnwindSafe for NetworkController
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