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 !Freeze for NetworkState
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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