Struct ckb_network::network::NetworkController

source ·
pub struct NetworkController { /* private fields */ }
Expand description

Network controller

Implementations§

source§

impl NetworkController

source

pub fn init_ckb2023(&self)

Set ckb2023 start

source

pub fn load_ckb2023(&self) -> bool

Get ckb2023 flag

source

pub fn public_urls(&self, max_urls: usize) -> Vec<(String, u8)>

Node listen address list

source

pub fn version(&self) -> &String

ckb version

source

pub fn node_id(&self) -> String

Node peer id’s base58 format string

source

pub fn p2p_control(&self) -> &ServiceControl

p2p service control

source

pub fn add_node(&self, address: Multiaddr)

Dial remote node

source

pub fn remove_node(&self, peer_id: &PeerId)

Disconnect session with peer id

source

pub fn get_banned_addrs(&self) -> Vec<BannedAddr>

Get banned peer list

source

pub fn clear_banned_addrs(&self)

Clear banned list

source

pub fn addr_info(&self, addr: &Multiaddr) -> Option<AddrInfo>

Get address info from peer store

source

pub fn ban(&self, address: IpNetwork, ban_until: u64, ban_reason: String)

Ban an ip

source

pub fn unban(&self, address: &IpNetwork)

Unban an ip

source

pub fn connected_peers(&self) -> Vec<(PeerIndex, Peer)>

Return all connected peers’ information

source

pub fn ban_peer( &self, peer_index: PeerIndex, duration: Duration, reason: String )

Ban an peer through peer index

source

pub fn broadcast( &self, proto_id: ProtocolId, data: Bytes ) -> Result<(), SendErrorKind>

Broadcast a message to all connected peers

source

pub fn quick_broadcast( &self, proto_id: ProtocolId, data: Bytes ) -> Result<(), SendErrorKind>

Broadcast a message to all connected peers through quick queue

source

pub fn send_message_to( &self, session_id: SessionId, proto_id: ProtocolId, data: Bytes ) -> Result<(), SendErrorKind>

Send message to one connected peer

source

pub fn is_active(&self) -> bool

network message processing controller, always true, if false, discard any received messages

source

pub fn set_active(&self, active: bool)

Change active status, if set false discard any received messages

source

pub fn protocols(&self) -> Vec<(ProtocolId, String, Vec<String>)>

Return all connected peers’ protocols info

source

pub fn ping_peers(&self)

Try ping all connected peers

Trait Implementations§

source§

impl Clone for NetworkController

source§

fn clone(&self) -> NetworkController

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> AsAny for T
where T: Any,

source§

fn as_any(&self) -> &(dyn Any + 'static)

Cast to trait Any
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> DynClone for T
where T: Clone,

source§

fn __clone_box(&self, _: Private) -> *mut ()

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V