Merge branch 'master' into gav

This commit is contained in:
Gav Wood 2016-01-06 13:55:05 +01:00
commit be7bfd51a7
4 changed files with 36 additions and 2 deletions

View File

@ -15,7 +15,7 @@ mio = "0.4.4"
rand = "0.3.12"
time = "0.1.34"
tiny-keccak = "1.0"
rocksdb = "0.2.1"
rocksdb = "0.2"
lazy_static = "0.1.*"
secp256k1 = "0.5.1"
rust-crypto = "0.2.34"

View File

@ -320,6 +320,26 @@ impl<'a> From<&'a U256> for H256 {
}
}
impl From<H256> for Address {
fn from(value: H256) -> Address {
unsafe {
let mut ret: Address = ::std::mem::uninitialized();
::std::ptr::copy(value.as_ptr().offset(12), ret.as_mut_ptr(), 20);
ret
}
}
}
impl From<Address> for H256 {
fn from(value: Address) -> H256 {
unsafe {
let mut ret = H256::new();
::std::ptr::copy(value.as_ptr(), ret.as_mut_ptr().offset(12), 20);
ret
}
}
}
impl_hash!(H32, 4);
impl_hash!(H64, 8);
impl_hash!(H128, 16);
@ -382,5 +402,13 @@ mod tests {
assert!(my_bloom.contains_bloom(&address.sha3()));
assert!(my_bloom.contains_bloom(&topic.sha3()));
}
#[test]
fn from_and_to_address() {
let address = Address::from_str("ef2d6d194084c2de36e0dabfce45d046b37d1106").unwrap();
let h = H256::from(address.clone());
let a = Address::from(h);
assert_eq!(address, a);
}
}

View File

@ -2,8 +2,14 @@
///
/// # Example
/// ```
<<<<<<< HEAD
/// extern crate ethcore_util;
/// use ethcore_util::semantic_version::*;
=======
/// extern crate ethcore_util as util;
/// use util::semantic_version::*;
///
>>>>>>> master
/// fn main() {
/// assert_eq!(SemanticVersion::new(1, 2, 3).as_u32(), 0x010203);
/// }