1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
pub use uint::U256;
construct_fixed_hash!{
pub struct H160(20);
}
construct_fixed_hash!{
pub struct H256(32);
}
impl_fixed_hash_conversions!(H256, H160);
pub type Address = H160;
impl From<U256> for H256 {
fn from(uint: U256) -> H256 {
let mut hash = H256::zero();
uint.to_big_endian(hash.as_bytes_mut());
hash
}
}
impl<'a> From<&'a U256> for H256 {
fn from(uint: &'a U256) -> H256 {
let mut hash: H256 = H256::zero();
uint.to_big_endian(hash.as_bytes_mut());
hash
}
}
impl From<H256> for U256 {
fn from(hash: H256) -> U256 {
U256::from(hash.as_bytes())
}
}
impl<'a> From<&'a H256> for U256 {
fn from(hash: &'a H256) -> U256 {
U256::from(hash.as_bytes())
}
}