Struct ckb_network::network::NetworkState
source · pub struct NetworkState { /* private fields */ }
Expand description
The global shared state of the network module
Implementations§
source§impl NetworkState
impl NetworkState
sourcepub fn from_config(config: NetworkConfig) -> Result<NetworkState, Error>
pub fn from_config(config: NetworkConfig) -> Result<NetworkState, Error>
Init from config
sourcepub fn required_flags(self, flags: Flags) -> Self
pub fn required_flags(self, flags: Flags) -> Self
use to discovery get nodes message to announce what kind of node information need from the other peer
default with Flags::SYNC | Flags::DISCOVERY | Flags::RELAY
sourcepub fn with_peer_registry<F, T>(&self, callback: F) -> Twhere
F: FnOnce(&PeerRegistry) -> T,
pub fn with_peer_registry<F, T>(&self, callback: F) -> Twhere
F: FnOnce(&PeerRegistry) -> T,
For restrict lock in inner scope
sourcepub fn local_peer_id(&self) -> &PeerId
pub fn local_peer_id(&self) -> &PeerId
Get peer id of local node
sourcepub fn local_private_key(&self) -> &SecioKeyPair
pub fn local_private_key(&self) -> &SecioKeyPair
Use on test
sourcepub fn public_urls(&self, max_urls: usize) -> Vec<(String, u8)>
pub fn public_urls(&self, max_urls: usize) -> Vec<(String, u8)>
Get local node’s listen address list
sourcepub fn get_protocol_ids<F: Fn(ProtocolId) -> bool>(
&self,
filter: F
) -> Vec<ProtocolId>
pub fn get_protocol_ids<F: Fn(ProtocolId) -> bool>( &self, filter: F ) -> Vec<ProtocolId>
use a filter to get protocol id list
sourcepub fn dial_identify(&self, p2p_control: &ServiceControl, addr: Multiaddr)
pub fn dial_identify(&self, p2p_control: &ServiceControl, addr: Multiaddr)
Dial just identify protocol
sourcepub fn dial_feeler(&self, p2p_control: &ServiceControl, addr: Multiaddr)
pub fn dial_feeler(&self, p2p_control: &ServiceControl, addr: Multiaddr)
Dial just feeler protocol
Auto Trait Implementations§
impl !RefUnwindSafe for NetworkState
impl Send for NetworkState
impl Sync for NetworkState
impl Unpin for NetworkState
impl UnwindSafe for NetworkState
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