Update parity-scale-codec to 2.0 (#7994)

* update cargo.toml

* use 2.0 in mmmr
This commit is contained in:
Guillaume Thiolliere
2021-01-29 13:22:45 +01:00
committed by GitHub
parent bea4a6524d
commit f48296e9ad
179 changed files with 316 additions and 383 deletions
+2 -2
View File
@@ -16,7 +16,7 @@ targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
serde = { version = "1.0.101", optional = true, features = ["derive"] }
codec = { package = "parity-scale-codec", version = "1.3.6", default-features = false, features = ["derive"] }
codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false, features = ["derive"] }
sp-core = { version = "2.0.0", default-features = false, path = "../core" }
sp-application-crypto = { version = "2.0.0", default-features = false, path = "../application-crypto" }
sp-arithmetic = { version = "2.0.0", default-features = false, path = "../arithmetic" }
@@ -26,7 +26,7 @@ log = { version = "0.4.8", optional = true }
paste = "0.1.6"
rand = { version = "0.7.2", optional = true }
impl-trait-for-tuples = "0.2.0"
parity-util-mem = { version = "0.8.0", default-features = false, features = ["primitive-types"] }
parity-util-mem = { version = "0.9.0", default-features = false, features = ["primitive-types"] }
hash256-std-hasher = { version = "0.15.2", default-features = false }
either = { version = "1.5", default-features = false }
@@ -107,13 +107,13 @@ impl Era {
}
impl Encode for Era {
fn encode_to<T: Output>(&self, output: &mut T) {
fn encode_to<T: Output + ?Sized>(&self, output: &mut T) {
match self {
Era::Immortal => output.push_byte(0),
Era::Mortal(period, phase) => {
let quantize_factor = (*period as u64 >> 12).max(1);
let encoded = (period.trailing_zeros() - 1).max(1).min(15) as u16 | ((phase / quantize_factor) << 4) as u16;
output.push(&encoded);
encoded.encode_to(output);
}
}
}
@@ -106,12 +106,12 @@ impl<Number, Hash> Encode for Header<Number, Hash> where
Hash: HashT,
Hash::Output: Encode,
{
fn encode_to<T: Output>(&self, dest: &mut T) {
dest.push(&self.parent_hash);
dest.push(&<<<Number as HasCompact>::Type as EncodeAsRef<_>>::RefType>::from(&self.number));
dest.push(&self.state_root);
dest.push(&self.extrinsics_root);
dest.push(&self.digest);
fn encode_to<T: Output + ?Sized>(&self, dest: &mut T) {
self.parent_hash.encode_to(dest);
<<<Number as HasCompact>::Type as EncodeAsRef<_>>::RefType>::from(&self.number).encode_to(dest);
self.state_root.encode_to(dest);
self.extrinsics_root.encode_to(dest);
self.digest.encode_to(dest);
}
}
+1 -1
View File
@@ -247,7 +247,7 @@ impl<'a, Xt> Deserialize<'a> for Block<Xt> where Block<Xt>: Decode {
fn deserialize<D: Deserializer<'a>>(de: D) -> Result<Self, D::Error> {
let r = <Vec<u8>>::deserialize(de)?;
Decode::decode(&mut &r[..])
.map_err(|e| DeError::custom(format!("Invalid value passed into decode: {}", e.what())))
.map_err(|e| DeError::custom(format!("Invalid value passed into decode: {}", e)))
}
}