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§

The ordered Patricia tree root of the given input.

The Patricia tree root of the given mapping.

Provided Methods§

Produce the hash of some byte-slice.

Produce the hash of some codec-encodable value.

Examples found in repository?
src/generic/header.rs (line 173)
172
173
174
	pub fn hash(&self) -> Hash::Output {
		Hash::hash_of(self)
	}
More examples
Hide additional 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())
	}

Implementors§