Merge branch 'master' into jsonrpc2

This commit is contained in:
debris
2016-02-15 10:53:01 +01:00
31 changed files with 927 additions and 109 deletions

View File

@@ -74,7 +74,6 @@ impl From<::secp256k1::Error> for CryptoError {
match e {
::secp256k1::Error::InvalidMessage => CryptoError::InvalidMessage,
::secp256k1::Error::InvalidPublicKey => CryptoError::InvalidPublic,
::secp256k1::Error::InvalidSignature => CryptoError::InvalidSignature,
::secp256k1::Error::InvalidSecretKey => CryptoError::InvalidSecret,
_ => CryptoError::InvalidSignature,
}

View File

@@ -296,7 +296,7 @@ macro_rules! impl_hash {
try!(write!(f, "{:02x}", i));
}
try!(write!(f, ""));
for i in &self.0[$size - 4..$size] {
for i in &self.0[$size - 2..$size] {
try!(write!(f, "{:02x}", i));
}
Ok(())
@@ -647,7 +647,7 @@ mod tests {
fn hash() {
let h = H64([0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef]);
assert_eq!(H64::from_str("0123456789abcdef").unwrap(), h);
assert_eq!(format!("{}", h), "0123…89abcdef");
assert_eq!(format!("{}", h), "0123…cdef");
assert_eq!(format!("{:?}", h), "0123456789abcdef");
assert_eq!(h.hex(), "0123456789abcdef");
assert!(h == h);

View File

@@ -19,9 +19,17 @@
#![feature(augmented_assignments)]
#![feature(associated_consts)]
#![feature(plugin)]
#![plugin(clippy)]
#![allow(needless_range_loop, match_bool)]
#![feature(catch_panic)]
// Clippy settings
#![plugin(clippy)]
// TODO [todr] not really sure
#![allow(needless_range_loop)]
// Shorter than if-else
#![allow(match_bool)]
// We use that to be more explicit about handled cases
#![allow(match_same_arms)]
// Keeps consistency (all lines with `.clone()`) and helpful when changing ref to non-ref.
#![allow(clone_on_copy)]
//! Ethcore-util library
//!

View File

@@ -211,7 +211,7 @@ impl Discovery {
}
let mut ret:Vec<&NodeId> = Vec::new();
for (_, nodes) in found {
for nodes in found.values() {
for n in nodes {
if ret.len() < BUCKET_SIZE as usize /* && n->endpoint && n->endpoint.isAllowed() */ {
ret.push(n);

View File

@@ -325,7 +325,7 @@ impl Session {
let mut rlp = RlpStream::new();
rlp.append(&(PACKET_DISCONNECT as u32));
rlp.begin_list(1);
rlp.append(&(reason.clone() as u32));
rlp.append(&(reason as u32));
self.connection.send_packet(&rlp.out()).ok();
NetworkError::Disconnect(reason)
}

View File

@@ -104,7 +104,7 @@ impl<F> OnPanicListener for F
}
fn convert_to_string(t: &Box<Any + Send>) -> Option<String> {
let as_str = t.downcast_ref::<&'static str>().map(|t| t.clone().to_owned());
let as_str = t.downcast_ref::<&'static str>().cloned().map(|t| t.to_owned());
let as_string = t.downcast_ref::<String>().cloned();
as_str.or(as_string)

View File

@@ -408,7 +408,7 @@ impl Decodable for Vec<u8> {
fn decode<D>(decoder: &D) -> Result<Self, DecoderError> where D: Decoder {
decoder.read_value(| bytes | {
let mut res = vec![];
res.extend(bytes);
res.extend_from_slice(bytes);
Ok(res)
})
}

View File

@@ -293,7 +293,7 @@ impl<'a> Iterator for TrieDBIterator<'a> {
fn next(&mut self) -> Option<Self::Item> {
let b = match self.trail.last_mut() {
Some(ref mut b) => { b.increment(); b.clone() },
Some(mut b) => { b.increment(); b.clone() },
None => return None
};
match (b.status, b.node) {
@@ -309,9 +309,8 @@ impl<'a> Iterator for TrieDBIterator<'a> {
self.trail.pop();
self.next()
},
(Status::At, Node::Leaf(_, v)) => Some((self.key(), v)),
(Status::At, Node::Leaf(_, v)) | (Status::At, Node::Branch(_, Some(v))) => Some((self.key(), v)),
(Status::At, Node::Extension(_, d)) => self.descend_next(d),
(Status::At, Node::Branch(_, Some(v))) => Some((self.key(), v)),
(Status::At, Node::Branch(_, _)) => self.next(),
(Status::AtChild(i), Node::Branch(children, _)) if children[i].len() > 0 => {
match i {