mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-29 21:57:55 +00:00
Update fixed-hash & uint utilities (#1078)
* [core/primitives] Update crunchy 0.1 => 0.2
* [core/primitives] Update fixed-hash 0.2 => 0.3.0-beta
* [core/primitives] Update `uint` 0.4 => 0.5.0-beta
* [core/state-machine] Fix errors emerged by fixed-hash update
* [core/state-db] Fix errors that emerged from fixed-hash update
* [core/sr-io] Fix errors that emerged from the fixed-hash update
* [core/trie] Fix errors emerged from fixed-hash updates
* [core/trie] Make use of new Hash::as_fixed_bytes_mut method in tests
* [core/sr-primitives] Fix errors emerged from updating fixed-hash
* [core/executor] Fix errors that emerged from fixed-hash update
* [core/test-runtime] Fix errors that emerged from updating fixed-hash
* [core/test-runtime] Fix an error that emerged from fixed-hash update
* [core/transaction-pool] Fix errors that emerged from updating fixed-hash
* Add From<u64> impl for hash types defined in core/primitives
* [core/client/db] Fix errors that emerged from fixed-hash update
* [core/{client/network/rpc}]: Fix errors emerged by fixed-hash update
* [node/{cli/executor/runtime}]: Fix errors emerged by updating fixed-hash
* [core/network]: Fix bug in parsing constant str
* Update Cargo.lock
- Add crunchy 0.2.1
- fixed-hash 0.2.2 => 0.3.0-beta.3
- Add static-assertions 0.2.5
- uint 0.4.1 => 0.5.0-beta.1
* [core/primitives]: Add fixed-hash/rustc-hex feature for FromStr impl
* [core/primitives] No longer provide From<u64> impl for hash types if byteorder support is not enabled
* [core/primitives] Revert to using From impl again in primitives tests
* [core/..] Fix some bugs that emerged by recent fixed-hash updates
* Update a bunch of Cargo.lock files
* [core/state-db] Re-add whitespace between attr and extern crate/mod
* [core/primitives] Fix bug in From<u64> impl for hash types using the wrong feature guard
This commit is contained in:
committed by
Bastian Köcher
parent
9072fce658
commit
660c747c51
@@ -35,7 +35,7 @@ macro_rules! impl_rest {
|
||||
impl<'de> Deserialize<'de> for $name {
|
||||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: Deserializer<'de> {
|
||||
bytes::deserialize_check_len(deserializer, bytes::ExpectedLen::Exact($len))
|
||||
.map(|x| (&*x).into())
|
||||
.map(|x| $name::from_slice(&x))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,12 +49,29 @@ macro_rules! impl_rest {
|
||||
<[u8; $len] as ::codec::Decode>::decode(input).map($name)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
impl From<u64> for $name {
|
||||
fn from(val: u64) -> Self {
|
||||
Self::from_low_u64_be(val)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
construct_hash!(H160, 20);
|
||||
construct_hash!(H256, 32);
|
||||
construct_hash!(H512, 64);
|
||||
construct_fixed_hash!{
|
||||
/// Fixed-size uninterpreted hash type with 20 bytes (160 bits) size.
|
||||
pub struct H160(20);
|
||||
}
|
||||
construct_fixed_hash!{
|
||||
/// Fixed-size uninterpreted hash type with 32 bytes (256 bits) size.
|
||||
pub struct H256(32);
|
||||
}
|
||||
construct_fixed_hash!{
|
||||
/// Fixed-size uninterpreted hash type with 64 bytes (512 bits) size.
|
||||
pub struct H512(64);
|
||||
}
|
||||
|
||||
impl_rest!(H160, 20);
|
||||
impl_rest!(H256, 32);
|
||||
impl_rest!(H512, 64);
|
||||
@@ -113,7 +130,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_heapsizeof() {
|
||||
use heapsize::HeapSizeOf;
|
||||
let h = H256::new();
|
||||
let h = H256::zero();
|
||||
assert_eq!(h.heap_size_of_children(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user