diff --git a/src/network/host.rs b/src/network/host.rs index b562ca765..abe1cbfcc 100644 --- a/src/network/host.rs +++ b/src/network/host.rs @@ -223,7 +223,7 @@ enum ConnectionEntry { /// Root IO handler. Manages protocol handlers, IO timers and network connections. pub struct Host where Message: Send { - info: HostInfo, + pub info: HostInfo, udp_socket: UdpSocket, listener: TcpListener, connections: Slab, diff --git a/src/network/service.rs b/src/network/service.rs index 401c74634..48cc11152 100644 --- a/src/network/service.rs +++ b/src/network/service.rs @@ -8,15 +8,19 @@ use io::*; /// `Message` defines a notification data type. pub struct NetworkService where Message: Send + 'static { io_service: IoService>, + host_info: String, } impl NetworkService where Message: Send + 'static { /// Starts IO event loop pub fn start() -> Result, UtilError> { let mut io_service = try!(IoService::>::start()); - try!(io_service.register_handler(Box::new(Host::new()))); + let host = Box::new(Host::new()); + let host_info = host.info.client_version.clone(); + try!(io_service.register_handler(host)); Ok(NetworkService { - io_service: io_service + io_service: io_service, + host_info: host_info, }) } @@ -41,9 +45,16 @@ impl NetworkService where Message: Send + 'static { Ok(()) } + /// Returns host identifier string as advertised to other peers + pub fn host_info(&self) -> String { + self.host_info.clone() + } + + /// Returns underlying io service. pub fn io(&mut self) -> &mut IoService> { &mut self.io_service } + }