Struct ethcore_network::NetworkService
[−]
[src]
pub struct NetworkService { /* fields omitted */ }
IO Service with networking
Message
defines a notification data type.
Methods
impl NetworkService
[src]
fn new(config: NetworkConfiguration) -> Result<NetworkService, NetworkError>
Starts IO event loop
fn register_protocol(&self,
handler: Arc<NetworkProtocolHandler + Send + Sync>,
protocol: ProtocolId,
packet_count: u8,
versions: &[u8])
-> Result<(), NetworkError>
handler: Arc<NetworkProtocolHandler + Send + Sync>,
protocol: ProtocolId,
packet_count: u8,
versions: &[u8])
-> Result<(), NetworkError>
Regiter a new protocol handler with the event loop.
fn host_info(&self) -> String
Returns host identifier string as advertised to other peers
fn io(&self) -> &IoService<NetworkIoMessage>
Returns underlying io service.
fn stats(&self) -> &NetworkStats
Returns network statistics.
fn config(&self) -> &NetworkConfiguration
Returns network configuration.
fn external_url(&self) -> Option<String>
Returns external url if available.
fn local_url(&self) -> Option<String>
Returns external url if available.
fn start(&self) -> Result<(), NetworkError>
Start network IO
fn stop(&self) -> Result<(), NetworkError>
Stop network IO
fn connected_peers(&self) -> Vec<PeerId>
Get a list of all connected peers by id.
fn add_reserved_peer(&self, peer: &str) -> Result<(), NetworkError>
Try to add a reserved peer.
fn remove_reserved_peer(&self, peer: &str) -> Result<(), NetworkError>
Try to remove a reserved peer.
fn set_non_reserved_mode(&self, mode: NonReservedPeerMode)
Set the non-reserved peer mode.
fn with_context<F>(&self, protocol: ProtocolId, action: F) where F: Fn(&NetworkContext)
Executes action in the network context
fn with_context_eval<F, T>(&self, protocol: ProtocolId, action: F) -> Option<T> where F: Fn(&NetworkContext) -> T
Evaluates function in the network context
Trait Implementations
impl MayPanic for NetworkService
[src]
fn on_panic<F>(&self, closure: F) where F: OnPanicListener
closure
will be invoked whenever panic in thread is caught