Fixing warnings (#1321)

This commit is contained in:
Tomasz Drwięga 2016-06-18 15:11:10 +02:00 committed by Gav Wood
parent c1c64bedc2
commit 81df97a737
6 changed files with 12 additions and 12 deletions

View File

@ -229,11 +229,11 @@ impl State {
// collect all the addresses which have changed.
let addresses = self.cache.borrow().iter().map(|(addr, _)| addr.clone()).collect::<Vec<_>>();
for a in addresses.iter() {
if self.code(a).map(|c| c.sha3() == broken_dao).unwrap_or(false) {
for a in &addresses {
if self.code(a).map_or(false, |c| c.sha3() == broken_dao) {
// Figure out if the balance has been reduced.
let maybe_original = SecTrieDB::new(self.db.as_hashdb(), &self.root).expect(SEC_TRIE_DB_UNWRAP_STR).get(&a).map(Account::from_rlp);
if maybe_original.map(|original| *original.balance() > self.balance(a)).unwrap_or(false) {
if maybe_original.map_or(false, |original| *original.balance() > self.balance(a)) {
return Err(Error::Transaction(TransactionError::DAORescue));
}
}

View File

@ -113,6 +113,7 @@ fn can_collect_garbage() {
}
#[test]
#[cfg_attr(feature="dev", allow(useless_vec))]
fn can_generate_gas_price_statistics() {
let client_result = generate_dummy_client_with_data(16, 1, &vec_into![0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]);
let client = client_result.reference();

View File

@ -140,7 +140,7 @@ pub fn create_test_block_with_data(header: &Header, transactions: &[SignedTransa
}
pub fn generate_dummy_client(block_number: u32) -> GuardedTempResult<Arc<Client>> {
generate_dummy_client_with_spec_and_data(Spec::new_test, block_number, 0, &(vec![]))
generate_dummy_client_with_spec_and_data(Spec::new_test, block_number, 0, &[])
}
pub fn generate_dummy_client_with_data(block_number: u32, txs_per_block: usize, tx_gas_prices: &[U256]) -> GuardedTempResult<Arc<Client>> {
@ -205,7 +205,7 @@ pub fn generate_dummy_client_with_spec_and_data<F>(get_test_spec: F, block_numbe
if let Err(e) = client.import_block(b.rlp_bytes()) {
panic!("error importing block which is valid by definition: {:?}", e);
}
last_header = BlockView::new(&b.rlp_bytes()).header();
db = b.drain();
}

View File

@ -1170,7 +1170,7 @@ impl ChainSync {
.expect("chain.tree_route and chain.find_uncles only return hahses of blocks that are in the blockchain. qed.")).number();
hash_rlp.append(&block_hash);
hash_rlp.append(&number);
rlp_stream.append_raw(&hash_rlp.as_raw(), 1);
rlp_stream.append_raw(hash_rlp.as_raw(), 1);
}
Some(rlp_stream.out())
}

View File

@ -124,12 +124,11 @@ impl EthSync {
/// Creates and register protocol with the network service
pub fn new(config: SyncConfig, chain: Arc<Client>) -> Arc<EthSync> {
let sync = ChainSync::new(config, chain.deref());
let sync = Arc::new(EthSync {
Arc::new(EthSync {
chain: chain,
sync: RwLock::new(sync),
io_channel: RwLock::new(IoChannel::disconnected()),
});
sync
})
}
/// Register protocol with the network service

View File

@ -252,7 +252,7 @@ impl<'s, Message> NetworkContext<'s, Message> where Message: Send + Sync + Clone
/// Check if the session is still active.
pub fn is_expired(&self) -> bool {
self.session.as_ref().map(|s| s.lock().unwrap().expired()).unwrap_or(false)
self.session.as_ref().map_or(false, |s| s.lock().unwrap().expired())
}
/// Register a new IO timer. 'IoHandler::timeout' will be called with the token.
@ -643,7 +643,7 @@ impl<Message> Host<Message> where Message: Send + Sync + Clone {
}
if s.done() {
io.deregister_stream(token).unwrap_or_else(|e| debug!("Error deregistering stream: {:?}", e));
}
}
}
}
@ -769,7 +769,7 @@ impl<Message> Host<Message> where Message: Send + Sync + Clone {
}
if deregister {
io.deregister_stream(token).unwrap_or_else(|e| debug!("Error deregistering stream: {:?}", e));
}
}
}
fn update_nodes(&self, io: &IoContext<NetworkIoMessage<Message>>, node_changes: TableUpdates) {