Trait sp_runtime::traits::Hash
source · pub trait Hash: 'static + MaybeSerializeDeserialize + Debug + Clone + Eq + PartialEq + Hasher<Out = Self::Output> {
type Output: Member + MaybeSerializeDeserialize + Debug + Hash + AsRef<[u8]> + AsMut<[u8]> + Copy + Default + Encode + Decode + MaxEncodedLen + TypeInfo;
fn ordered_trie_root(
input: Vec<Vec<u8>>,
state_version: StateVersion
) -> Self::Output;
fn trie_root(
input: Vec<(Vec<u8>, Vec<u8>)>,
state_version: StateVersion
) -> Self::Output;
fn hash(s: &[u8]) -> Self::Output { ... }
fn hash_of<S: Encode>(s: &S) -> Self::Output { ... }
}
Expand description
Abstraction around hashing
Required Associated Types§
Required Methods§
sourcefn ordered_trie_root(
input: Vec<Vec<u8>>,
state_version: StateVersion
) -> Self::Output
fn ordered_trie_root(
input: Vec<Vec<u8>>,
state_version: StateVersion
) -> Self::Output
The ordered Patricia tree root of the given input
.
Provided Methods§
sourcefn hash_of<S: Encode>(s: &S) -> Self::Output
fn hash_of<S: Encode>(s: &S) -> Self::Output
Produce the hash of some codec-encodable value.
Examples found in repository?
More examples
src/traits.rs (line 892)
891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931
fn hash(&self) -> Self::Hash {
<Self::Hashing as Hash>::hash_of(self)
}
}
/// Something which fulfills the abstract idea of a Substrate block. It has types for
/// `Extrinsic` pieces of information as well as a `Header`.
///
/// You can get an iterator over each of the `extrinsics` and retrieve the `header`.
pub trait Block: Clone + Send + Sync + Codec + Eq + MaybeSerialize + Debug + 'static {
/// Type for extrinsics.
type Extrinsic: Member + Codec + Extrinsic + MaybeSerialize;
/// Header type.
type Header: Header<Hash = Self::Hash>;
/// Block hash type.
type Hash: Member
+ MaybeSerializeDeserialize
+ Debug
+ sp_std::hash::Hash
+ Ord
+ Copy
+ MaybeDisplay
+ Default
+ SimpleBitOps
+ Codec
+ AsRef<[u8]>
+ AsMut<[u8]>
+ TypeInfo;
/// Returns a reference to the header.
fn header(&self) -> &Self::Header;
/// Returns a reference to the list of extrinsics.
fn extrinsics(&self) -> &[Self::Extrinsic];
/// Split the block into header and list of extrinsics.
fn deconstruct(self) -> (Self::Header, Vec<Self::Extrinsic>);
/// Creates new block from header and extrinsics.
fn new(header: Self::Header, extrinsics: Vec<Self::Extrinsic>) -> Self;
/// Returns the hash of the block.
fn hash(&self) -> Self::Hash {
<<Self::Header as Header>::Hashing as Hash>::hash_of(self.header())
}