Fixing warnings

This commit is contained in:
Tomasz Drwięga 2016-03-12 10:07:55 +01:00
parent e10457d235
commit 4b6e1dd4d2
9 changed files with 74 additions and 23 deletions

View File

@ -523,7 +523,7 @@ mod tests {
let engine = spec.to_engine().unwrap(); let engine = spec.to_engine().unwrap();
let mut config = BlockQueueConfig::default(); let mut config = BlockQueueConfig::default();
config.max_mem_use = super::MIN_MEM_LIMIT; // empty queue uses about 15000 config.max_mem_use = super::MIN_MEM_LIMIT; // empty queue uses about 15000
let mut queue = BlockQueue::new(config, Arc::new(engine), IoChannel::disconnected()); let queue = BlockQueue::new(config, Arc::new(engine), IoChannel::disconnected());
assert!(!queue.queue_info().is_full()); assert!(!queue.queue_info().is_full());
let mut blocks = get_good_dummy_block_seq(50); let mut blocks = get_good_dummy_block_seq(50);
for b in blocks.drain(..) { for b in blocks.drain(..) {

View File

@ -28,9 +28,15 @@ pub struct MemoryCache {
blooms: HashMap<BloomIndex, H2048>, blooms: HashMap<BloomIndex, H2048>,
} }
impl Default for MemoryCache {
fn default() -> Self {
MemoryCache::new()
}
}
impl MemoryCache { impl MemoryCache {
/// Default constructor for MemoryCache /// Default constructor for MemoryCache
pub fn new() -> MemoryCache { pub fn new() -> Self {
MemoryCache { blooms: HashMap::new() } MemoryCache { blooms: HashMap::new() }
} }

View File

@ -55,9 +55,15 @@ pub enum EachBlockWith {
UncleAndTransaction UncleAndTransaction
} }
impl Default for TestBlockChainClient {
fn default() -> Self {
TestBlockChainClient::new()
}
}
impl TestBlockChainClient { impl TestBlockChainClient {
/// Creates new test client. /// Creates new test client.
pub fn new() -> TestBlockChainClient { pub fn new() -> Self {
let mut client = TestBlockChainClient { let mut client = TestBlockChainClient {
blocks: RwLock::new(HashMap::new()), blocks: RwLock::new(HashMap::new()),

View File

@ -301,8 +301,14 @@ mod tests {
env_info: EnvInfo env_info: EnvInfo
} }
impl Default for TestSetup {
fn default() -> Self {
TestSetup::new()
}
}
impl TestSetup { impl TestSetup {
fn new() -> TestSetup { fn new() -> Self {
TestSetup { TestSetup {
state: get_temp_state(), state: get_temp_state(),
engine: get_test_spec().to_engine().unwrap(), engine: get_test_spec().to_engine().unwrap(),

View File

@ -255,8 +255,14 @@ mod tests {
numbers: HashMap<BlockNumber, H256>, numbers: HashMap<BlockNumber, H256>,
} }
impl Default for TestBlockChain {
fn default() -> Self {
TestBlockChain::new()
}
}
impl TestBlockChain { impl TestBlockChain {
pub fn new() -> TestBlockChain { pub fn new() -> Self {
TestBlockChain { TestBlockChain {
blocks: HashMap::new(), blocks: HashMap::new(),
numbers: HashMap::new(), numbers: HashMap::new(),

View File

@ -315,7 +315,7 @@ impl Configuration {
fn init_nodes(&self, spec: &Spec) -> Vec<String> { fn init_nodes(&self, spec: &Spec) -> Vec<String> {
let mut r = if self.args.flag_no_bootstrap { Vec::new() } else { spec.nodes().clone() }; let mut r = if self.args.flag_no_bootstrap { Vec::new() } else { spec.nodes().clone() };
if let Some(ref x) = self.args.flag_bootnodes { if let Some(ref x) = self.args.flag_bootnodes {
r.extend(x.split(",").map(|s| Self::normalize_enode(s).unwrap_or_else(|| die!("{}: Invalid node address format given for a boot node.", s)))); r.extend(x.split(',').map(|s| Self::normalize_enode(s).unwrap_or_else(|| die!("{}: Invalid node address format given for a boot node.", s))));
} }
r r
} }
@ -328,7 +328,7 @@ impl Configuration {
let host = IpAddr::from_str(host).unwrap_or_else(|_| die!("Invalid host given with `--nat extip:{}`", host)); let host = IpAddr::from_str(host).unwrap_or_else(|_| die!("Invalid host given with `--nat extip:{}`", host));
Some(SocketAddr::new(host, self.args.flag_port)) Some(SocketAddr::new(host, self.args.flag_port))
} else { } else {
listen_address.clone() listen_address
}; };
(listen_address, public_address) (listen_address, public_address)
} }
@ -389,7 +389,7 @@ impl Configuration {
} }
if self.args.cmd_list { if self.args.cmd_list {
println!("Known addresses:"); println!("Known addresses:");
for &(addr, _) in secret_store.accounts().unwrap().iter() { for &(addr, _) in &secret_store.accounts().unwrap() {
println!("{:?}", addr); println!("{:?}", addr);
} }
} }
@ -407,7 +407,11 @@ impl Configuration {
let spec = self.spec(); let spec = self.spec();
let net_settings = self.net_settings(&spec); let net_settings = self.net_settings(&spec);
let mut sync_config = SyncConfig::default(); let mut sync_config = SyncConfig::default();
sync_config.network_id = self.args.flag_networkid.as_ref().map(|id| U256::from_str(id).unwrap_or_else(|_| die!("{}: Invalid index given with --networkid", id))).unwrap_or(spec.network_id()); sync_config.network_id = self.args.flag_networkid.as_ref().map_or(spec.network_id(), |id| {
U256::from_str(id).unwrap_or_else(|_| {
die!("{}: Invalid index given with --networkid", id)
})
});
// Build client // Build client
let mut client_config = ClientConfig::default(); let mut client_config = ClientConfig::default();
@ -422,8 +426,7 @@ impl Configuration {
} }
} }
client_config.pruning = match self.args.flag_pruning.as_str() { client_config.pruning = match self.args.flag_pruning.as_str() {
"" => journaldb::Algorithm::Archive, "" | "archive" => journaldb::Algorithm::Archive,
"archive" => journaldb::Algorithm::Archive,
"pruned" => journaldb::Algorithm::EarlyMerge, "pruned" => journaldb::Algorithm::EarlyMerge,
// "fast" => journaldb::Algorithm::OverlayRecent, // TODO: @arkpar uncomment this once option 2 is merged. // "fast" => journaldb::Algorithm::OverlayRecent, // TODO: @arkpar uncomment this once option 2 is merged.
// "slow" => journaldb::Algorithm::RefCounted, // TODO: @gavofyork uncomment this once ref-count algo is merged. // "slow" => journaldb::Algorithm::RefCounted, // TODO: @gavofyork uncomment this once ref-count algo is merged.
@ -453,7 +456,7 @@ impl Configuration {
let cors = self.args.flag_rpccorsdomain.as_ref().unwrap_or(&self.args.flag_jsonrpc_cors); let cors = self.args.flag_rpccorsdomain.as_ref().unwrap_or(&self.args.flag_jsonrpc_cors);
// TODO: use this as the API list. // TODO: use this as the API list.
let apis = self.args.flag_rpcapi.as_ref().unwrap_or(&self.args.flag_jsonrpc_apis); let apis = self.args.flag_rpcapi.as_ref().unwrap_or(&self.args.flag_jsonrpc_apis);
let server_handler = setup_rpc_server(service.client(), sync.clone(), account_service.clone(), &url, cors, apis.split(",").collect()); let server_handler = setup_rpc_server(service.client(), sync.clone(), account_service.clone(), &url, cors, apis.split(',').collect());
if let Some(handler) = server_handler { if let Some(handler) = server_handler {
panic_handler.forward_from(handler.deref()); panic_handler.forward_from(handler.deref());
} }

View File

@ -364,7 +364,7 @@ mod tests {
fn reopen_fork() { fn reopen_fork() {
let mut dir = ::std::env::temp_dir(); let mut dir = ::std::env::temp_dir();
dir.push(H32::random().hex()); dir.push(H32::random().hex());
let (foo, bar, baz) = { let (foo, _bar, _baz) = {
let mut jdb = ArchiveDB::new(dir.to_str().unwrap()); let mut jdb = ArchiveDB::new(dir.to_str().unwrap());
// history is 1 // history is 1
let foo = jdb.insert(b"foo"); let foo = jdb.insert(b"foo");

View File

@ -120,9 +120,15 @@ impl AccountProvider for AccountService {
} }
} }
impl Default for AccountService {
fn default() -> Self {
AccountService::new()
}
}
impl AccountService { impl AccountService {
/// New account service with the default location /// New account service with the default location
pub fn new() -> AccountService { pub fn new() -> Self {
let secret_store = RwLock::new(SecretStore::new()); let secret_store = RwLock::new(SecretStore::new());
secret_store.write().unwrap().try_import_existing(); secret_store.write().unwrap().try_import_existing();
AccountService { AccountService {
@ -568,7 +574,7 @@ mod tests {
let temp = RandomTempPath::create_dir(); let temp = RandomTempPath::create_dir();
let mut sstore = SecretStore::new_test(&temp); let mut sstore = SecretStore::new_test(&temp);
let addr = sstore.new_account("test").unwrap(); let addr = sstore.new_account("test").unwrap();
let _ok = sstore.unlock_account(&addr, "test").unwrap(); sstore.unlock_account(&addr, "test").unwrap();
let secret = sstore.account_secret(&addr).unwrap(); let secret = sstore.account_secret(&addr).unwrap();
let kp = KeyPair::from_secret(secret).unwrap(); let kp = KeyPair::from_secret(secret).unwrap();
assert_eq!(Address::from(kp.public().sha3()), addr); assert_eq!(Address::from(kp.public().sha3()), addr);

View File

@ -160,12 +160,12 @@ impl Connection {
} }
} }
/// Get socket token /// Get socket token
pub fn token(&self) -> StreamToken { pub fn token(&self) -> StreamToken {
self.token self.token
} }
/// Replace socket token /// Replace socket token
pub fn set_token(&mut self, token: StreamToken) { pub fn set_token(&mut self, token: StreamToken) {
self.token = token; self.token = token;
} }
@ -261,13 +261,13 @@ pub struct EncryptedConnection {
} }
impl EncryptedConnection { impl EncryptedConnection {
/// Get socket token /// Get socket token
pub fn token(&self) -> StreamToken { pub fn token(&self) -> StreamToken {
self.connection.token self.connection.token
} }
/// Replace socket token /// Replace socket token
pub fn set_token(&mut self, token: StreamToken) { pub fn set_token(&mut self, token: StreamToken) {
self.connection.set_token(token); self.connection.set_token(token);
} }
@ -513,8 +513,14 @@ mod tests {
buf_size: usize, buf_size: usize,
} }
impl Default for TestSocket {
fn default() -> Self {
TestSocket::new()
}
}
impl TestSocket { impl TestSocket {
fn new() -> TestSocket { fn new() -> Self {
TestSocket { TestSocket {
read_buffer: vec![], read_buffer: vec![],
write_buffer: vec![], write_buffer: vec![],
@ -593,8 +599,14 @@ mod tests {
type TestConnection = GenericConnection<TestSocket>; type TestConnection = GenericConnection<TestSocket>;
impl Default for TestConnection {
fn default() -> Self {
TestConnection::new()
}
}
impl TestConnection { impl TestConnection {
pub fn new() -> TestConnection { pub fn new() -> Self {
TestConnection { TestConnection {
token: 999998888usize, token: 999998888usize,
socket: TestSocket::new(), socket: TestSocket::new(),
@ -609,8 +621,14 @@ mod tests {
type TestBrokenConnection = GenericConnection<TestBrokenSocket>; type TestBrokenConnection = GenericConnection<TestBrokenSocket>;
impl Default for TestBrokenConnection {
fn default() -> Self {
TestBrokenConnection::new()
}
}
impl TestBrokenConnection { impl TestBrokenConnection {
pub fn new() -> TestBrokenConnection { pub fn new() -> Self {
TestBrokenConnection { TestBrokenConnection {
token: 999998888usize, token: 999998888usize,
socket: TestBrokenSocket { error: "test broken socket".to_owned() }, socket: TestBrokenSocket { error: "test broken socket".to_owned() },