Struct ethcore_network_devp2p::NetworkService
source · [−]pub struct NetworkService { /* private fields */ }
Expand description
IO Service with networking
Message
defines a notification data type.
Implementations
sourceimpl NetworkService
impl NetworkService
sourcepub fn new(
config: NetworkConfiguration,
filter: Option<Arc<dyn ConnectionFilter>>
) -> Result<NetworkService, Error>
pub fn new(
config: NetworkConfiguration,
filter: Option<Arc<dyn ConnectionFilter>>
) -> Result<NetworkService, Error>
Starts IO event loop
sourcepub fn register_protocol(
&self,
handler: Arc<dyn NetworkProtocolHandler + Send + Sync>,
protocol: ProtocolId,
versions: &[(u8, u8)]
) -> Result<(), Error>
pub fn register_protocol(
&self,
handler: Arc<dyn NetworkProtocolHandler + Send + Sync>,
protocol: ProtocolId,
versions: &[(u8, u8)]
) -> Result<(), Error>
Register a new protocol handler with the event loop.
sourcepub fn io(&self) -> &IoService<NetworkIoMessage>
pub fn io(&self) -> &IoService<NetworkIoMessage>
Returns underlying io service.
sourcepub fn num_peers_range(&self) -> RangeInclusive<u32>
pub fn num_peers_range(&self) -> RangeInclusive<u32>
Returns the number of peers allowed.
sourcepub fn external_url(&self) -> Option<String>
pub fn external_url(&self) -> Option<String>
Returns external url if available.
sourcepub fn start(&self) -> Result<(), (Error, Option<SocketAddr>)>
pub fn start(&self) -> Result<(), (Error, Option<SocketAddr>)>
Start network IO.
In case of error, also returns the listening address for better error reporting.
sourcepub fn connected_peers(&self) -> Vec<PeerId>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
pub fn connected_peers(&self) -> Vec<PeerId>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
Get a list of all connected peers by id.
sourcepub fn remove_reserved_peer(&self, peer: &str) -> Result<(), Error>
pub fn remove_reserved_peer(&self, peer: &str) -> Result<(), Error>
Try to remove a reserved peer.
sourcepub fn set_non_reserved_mode(&self, mode: NonReservedPeerMode)
pub fn set_non_reserved_mode(&self, mode: NonReservedPeerMode)
Set the non-reserved peer mode.
sourcepub fn with_context<F>(&self, protocol: ProtocolId, action: F) where
F: FnOnce(&dyn NetworkContext),
pub fn with_context<F>(&self, protocol: ProtocolId, action: F) where
F: FnOnce(&dyn NetworkContext),
Executes action in the network context
sourcepub fn with_context_eval<F, T>(
&self,
protocol: ProtocolId,
action: F
) -> Option<T> where
F: FnOnce(&dyn NetworkContext) -> T,
pub fn with_context_eval<F, T>(
&self,
protocol: ProtocolId,
action: F
) -> Option<T> where
F: FnOnce(&dyn NetworkContext) -> T,
Evaluates function in the network context
Auto Trait Implementations
impl !RefUnwindSafe for NetworkService
impl Send for NetworkService
impl Sync for NetworkService
impl Unpin for NetworkService
impl !UnwindSafe for NetworkService
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more