Skip to content

Commit

Permalink
Combine scale-info feature into codec, and wire it through `ether…
Browse files Browse the repository at this point in the history
…eum-types` (#593)

* Start with Cargo.toml

* better features, version, and ethbloom

* feature

* better feature

* do bloom

* hack H64

* remaining ethereum hash types

* fix crate name in tests

* revert breaking changes to primitive-types

* Update primitive-types/tests/scale_info.rs

Co-authored-by: Andronik Ordian <write@reusable.software>

Co-authored-by: Andronik Ordian <write@reusable.software>
  • Loading branch information
JoshOrndorff and ordian committed Sep 30, 2021
1 parent 8e990ac commit df638ab
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
3 changes: 2 additions & 1 deletion ethbloom/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ fixed-hash = { path = "../fixed-hash", version = "0.7", default-features = false
impl-serde = { path = "../primitive-types/impls/serde", version = "0.3", default-features = false, optional = true }
impl-rlp = { path = "../primitive-types/impls/rlp", version = "0.3", default-features = false, optional = true }
impl-codec = { version = "0.5.0", path = "../primitive-types/impls/codec", default-features = false, optional = true }
scale-info = { version = "1.0", features = ["derive"], default-features = false, optional = true }

[dev-dependencies]
criterion = "0.3.0"
Expand All @@ -29,7 +30,7 @@ serialize = ["impl-serde"]
rustc-hex = ["fixed-hash/rustc-hex"]
arbitrary = ["fixed-hash/arbitrary"]
rlp = ["impl-rlp"]
codec = ["impl-codec"]
codec = ["impl-codec", "scale-info"]

[[bench]]
name = "bloom"
Expand Down
1 change: 1 addition & 0 deletions ethbloom/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ const BLOOM_SIZE: usize = 256;

construct_fixed_hash! {
/// Bloom hash type with 256 bytes (2048 bits) size.
#[cfg_attr(feature = "codec", derive(scale_info::TypeInfo))]
pub struct Bloom(BLOOM_SIZE);
}
#[cfg(feature = "rlp")]
Expand Down
3 changes: 2 additions & 1 deletion ethereum-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ primitive-types = { path = "../primitive-types", version = "0.10", features = ["
impl-serde = { path = "../primitive-types/impls/serde", version = "0.3.0", default-features = false, optional = true }
impl-rlp = { path = "../primitive-types/impls/rlp", version = "0.3", default-features = false, optional = true }
impl-codec = { version = "0.5.0", path = "../primitive-types/impls/codec", default-features = false, optional = true }
scale-info = { version = "1.0", features = ["derive"], default-features = false, optional = true }

[dev-dependencies]
serde_json = "1.0.41"
Expand All @@ -25,5 +26,5 @@ std = ["uint-crate/std", "fixed-hash/std", "ethbloom/std", "primitive-types/std"
serialize = ["impl-serde", "primitive-types/serde_no_std", "ethbloom/serialize"]
arbitrary = ["ethbloom/arbitrary", "fixed-hash/arbitrary", "uint-crate/arbitrary"]
rlp = ["impl-rlp", "ethbloom/rlp", "primitive-types/rlp"]
codec = ["impl-codec", "ethbloom/codec"]
codec = ["impl-codec", "ethbloom/codec", "scale-info", "primitive-types/scale-info"]
num-traits = ["primitive-types/num-traits"]
20 changes: 16 additions & 4 deletions ethereum-types/src/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,21 @@ impl_fixed_hash_serde!(H32, 4);
#[cfg(feature = "codec")]
impl_fixed_hash_codec!(H32, 4);

construct_fixed_hash! { pub struct H64(8); }
construct_fixed_hash! {
#[cfg_attr(feature = "codec", derive(scale_info::TypeInfo))]
pub struct H64(8);
}
#[cfg(feature = "rlp")]
impl_fixed_hash_rlp!(H64, 8);
#[cfg(feature = "serialize")]
impl_fixed_hash_serde!(H64, 8);
#[cfg(feature = "codec")]
impl_fixed_hash_codec!(H64, 8);

construct_fixed_hash! { pub struct H128(16); }
construct_fixed_hash! {
#[cfg_attr(feature = "codec", derive(scale_info::TypeInfo))]
pub struct H128(16);
}
#[cfg(feature = "rlp")]
impl_fixed_hash_rlp!(H128, 16);
#[cfg(feature = "serialize")]
Expand All @@ -48,7 +54,10 @@ impl_fixed_hash_codec!(H128, 16);

pub use primitive_types::{H160, H256};

construct_fixed_hash! { pub struct H264(33); }
construct_fixed_hash! {
#[cfg_attr(feature = "codec", derive(scale_info::TypeInfo))]
pub struct H264(33);
}
#[cfg(feature = "rlp")]
impl_fixed_hash_rlp!(H264, 33);
#[cfg(feature = "serialize")]
Expand All @@ -58,7 +67,10 @@ impl_fixed_hash_codec!(H264, 33);

pub use primitive_types::H512;

construct_fixed_hash! { pub struct H520(65); }
construct_fixed_hash! {
#[cfg_attr(feature = "codec", derive(scale_info::TypeInfo))]
pub struct H520(65);
}
#[cfg(feature = "rlp")]
impl_fixed_hash_rlp!(H520, 65);
#[cfg(feature = "serialize")]
Expand Down

0 comments on commit df638ab

Please sign in to comment.