diff --git a/src/client.rs b/src/client.rs index 4905fe094..2c87af249 100644 --- a/src/client.rs +++ b/src/client.rs @@ -105,6 +105,7 @@ pub struct Client { } impl Client { + /// Create a new client with given spec and DB path. pub fn new(spec: Spec, path: &Path, message_channel: IoChannel ) -> Result { let chain = Arc::new(RwLock::new(BlockChain::new(&spec.genesis_block(), path))); let engine = Arc::new(try!(spec.to_engine())); @@ -123,7 +124,7 @@ impl Client { }) } - + /// This is triggered by a message coming from a block queue when the block is ready for insertion pub fn import_verified_block(&mut self, bytes: Bytes) { let block = BlockView::new(&bytes); let header = block.header(); @@ -173,7 +174,7 @@ impl Client { return; } } - info!(target: "client", "Imported {}", header.hash()); + info!(target: "client", "Imported #{} ({})", header.number(), header.hash()); } } diff --git a/src/service.rs b/src/service.rs index da91451f9..da1f65f88 100644 --- a/src/service.rs +++ b/src/service.rs @@ -1,10 +1,3 @@ -//! Client service. -//! -//! -//! -//! -//! - use util::*; use sync::*; use spec::Spec; @@ -12,11 +5,13 @@ use error::*; use std::env; use client::Client; +/// Client service setup. Creates and registers client and network services with the IO subsystem. pub struct ClientService { _net_service: NetworkService, } impl ClientService { + /// Start the service in a separate thread. pub fn start(spec: Spec) -> Result { let mut net_service = try!(NetworkService::start()); info!("Starting {}", net_service.host_info()); @@ -37,13 +32,13 @@ impl ClientService { } } +/// IO interface for the Client handler struct ClientIoHandler { client: Arc> } impl IoHandler for ClientIoHandler { - fn initialize<'s>(&'s mut self, _io: &mut IoContext<'s, NetSyncMessage>) { - } + fn initialize<'s>(&'s mut self, _io: &mut IoContext<'s, NetSyncMessage>) { } fn message<'s>(&'s mut self, _io: &mut IoContext<'s, NetSyncMessage>, net_message: &'s mut NetSyncMessage) { match net_message { @@ -52,11 +47,11 @@ impl IoHandler for ClientIoHandler { &mut SyncMessage::BlockVerified(ref mut bytes) => { self.client.write().unwrap().import_verified_block(mem::replace(bytes, Bytes::new())); }, - _ => {}, + _ => {}, // ignore other messages } } - _ => {}, + _ => {}, // ignore other messages } }