Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 36 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 9 additions & 10 deletions core/primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,16 @@ version = "0.1.0"
authors = ["Parity Technologies <admin@parity.io>"]

[dependencies]
crunchy = { version = "0.2", default-features = false }
sr-std = { path = "../sr-std", default-features = false }
parity-codec = { version = "2.1", default-features = false }
parity-codec-derive = { version = "2.1", default-features = false }
fixed-hash = { version = "0.3.0", default-features = false }
rustc-hex = { version = "2.0", default-features = false }
serde = { version = "1.0", default-features = false }
serde_derive = { version = "1.0", optional = true }
uint = { version = "0.5.0-beta", default-features = false }
twox-hash = { version = "1.1.0", optional = true }
byteorder = { version = "1.1", default-features = false }
primitive-types = { version = "0.1", default-features = false, features = ["codec"] }
impl-serde = { version = "0.1", optional = true }
wasmi = { version = "0.4.2", optional = true }
hash-db = { git = "https://github.com/paritytech/trie", default-features = false }
hash256-std-hasher = { git = "https://github.com/paritytech/trie", default-features = false }
Expand All @@ -32,14 +31,14 @@ heapsize = "0.4"
[features]
default = ["std"]
std = [
"crunchy/std",
"wasmi",
"uint/std",
"fixed-hash/std",
"fixed-hash/heapsize",
"fixed-hash/byteorder",
"fixed-hash/rustc-hex",
"fixed-hash/libc",
"primitive-types/std",
"primitive-types/serde",
"primitive-types/heapsize",
"primitive-types/byteorder",
"primitive-types/rustc-hex",
"primitive-types/libc",
"impl-serde",
"parity-codec/std",
"hash256-std-hasher/std",
"hash-db/std",
Expand Down
1 change: 0 additions & 1 deletion core/primitives/src/authority_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
// You should have received a copy of the GNU General Public License
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.


#[cfg(feature = "std")]
use serde::{Serialize, Serializer, Deserialize, Deserializer};
use H256;
Expand Down
158 changes: 0 additions & 158 deletions core/primitives/src/bytes.rs

This file was deleted.

60 changes: 1 addition & 59 deletions core/primitives/src/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,65 +16,7 @@

//! A fixed hash type.

#[cfg(feature = "std")]
use serde::{Serialize, Serializer, Deserialize, Deserializer};

#[cfg(feature = "std")]
use bytes;

macro_rules! impl_rest {
($name: ident, $len: expr) => {
#[cfg(feature = "std")]
impl Serialize for $name {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: Serializer {
bytes::serialize(&self.0, serializer)
}
}

#[cfg(feature = "std")]
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| $name::from_slice(&x))
}
}

impl ::codec::Encode for $name {
fn using_encoded<R, F: FnOnce(&[u8]) -> R>(&self, f: F) -> R {
self.0.using_encoded(f)
}
}
impl ::codec::Decode for $name {
fn decode<I: ::codec::Input>(input: &mut I) -> Option<Self> {
<[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_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);
pub use primitive_types::{H160, H256, H512};

/// Hash conversion. Used to convert between unbound associated hash types in traits,
/// implemented by the same hash type.
Expand Down
3 changes: 1 addition & 2 deletions core/primitives/src/hexdisplay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl AsBytesRef for [u8] {
fn as_bytes_ref(&self) -> &[u8] { &self }
}

impl AsBytesRef for ::bytes::Vec<u8> {
impl AsBytesRef for Vec<u8> {
fn as_bytes_ref(&self) -> &[u8] { &self }
}

Expand Down Expand Up @@ -91,4 +91,3 @@ pub fn ascii_format(asciish: &[u8]) -> String {
}
r
}

Loading