@@ -113,6 +113,8 @@ type LeafOf<T, I> = <<T as Config<I>>::LeafData as primitives::LeafDataProvider>
113113
114114/// Hashing used for the pallet.
115115pub ( crate ) type HashingOf < T , I > = <T as Config < I > >:: Hashing ;
116+ /// Hash type used for the pallet.
117+ pub ( crate ) type HashOf < T , I > = <<T as Config < I > >:: Hashing as traits:: Hash >:: Output ;
116118
117119#[ frame_support:: pallet]
118120pub mod pallet {
@@ -146,24 +148,7 @@ pub mod pallet {
146148 ///
147149 /// Then we create a tuple of these two hashes, SCALE-encode it (concatenate) and
148150 /// hash, to obtain a new MMR inner node - the new peak.
149- type Hashing : traits:: Hash < Output = <Self as Config < I > >:: Hash > ;
150-
151- /// The hashing output type.
152- ///
153- /// This type is actually going to be stored in the MMR.
154- /// Required to be provided again, to satisfy trait bounds for storage items.
155- type Hash : traits:: Member
156- + traits:: MaybeSerializeDeserialize
157- + sp_std:: fmt:: Debug
158- + sp_std:: hash:: Hash
159- + AsRef < [ u8 ] >
160- + AsMut < [ u8 ] >
161- + Copy
162- + Default
163- + codec:: Codec
164- + codec:: EncodeLike
165- + scale_info:: TypeInfo
166- + MaxEncodedLen ;
151+ type Hashing : traits:: Hash ;
167152
168153 /// Data stored in the leaf nodes.
169154 ///
@@ -189,7 +174,7 @@ pub mod pallet {
189174 /// apart from having it in the storage. For instance you might output it in the header
190175 /// digest (see [`frame_system::Pallet::deposit_log`]) to make it available for Light
191176 /// Clients. Hook complexity should be `O(1)`.
192- type OnNewRoot : primitives:: OnNewRoot < <Self as Config < I > > :: Hash > ;
177+ type OnNewRoot : primitives:: OnNewRoot < HashOf < Self , I > > ;
193178
194179 /// Weights for this pallet.
195180 type WeightInfo : WeightInfo ;
@@ -198,8 +183,7 @@ pub mod pallet {
198183 /// Latest MMR Root hash.
199184 #[ pallet:: storage]
200185 #[ pallet:: getter( fn mmr_root_hash) ]
201- pub type RootHash < T : Config < I > , I : ' static = ( ) > =
202- StorageValue < _ , <T as Config < I > >:: Hash , ValueQuery > ;
186+ pub type RootHash < T : Config < I > , I : ' static = ( ) > = StorageValue < _ , HashOf < T , I > , ValueQuery > ;
203187
204188 /// Current size of the MMR (number of leaves).
205189 #[ pallet:: storage]
@@ -213,7 +197,7 @@ pub mod pallet {
213197 #[ pallet:: storage]
214198 #[ pallet:: getter( fn mmr_peak) ]
215199 pub type Nodes < T : Config < I > , I : ' static = ( ) > =
216- StorageMap < _ , Identity , NodeIndex , < T as Config < I > > :: Hash , OptionQuery > ;
200+ StorageMap < _ , Identity , NodeIndex , HashOf < T , I > , OptionQuery > ;
217201
218202 #[ pallet:: hooks]
219203 impl < T : Config < I > , I : ' static > Hooks < BlockNumberFor < T > > for Pallet < T , I > {
@@ -338,7 +322,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
338322 pub fn generate_proof (
339323 block_numbers : Vec < T :: BlockNumber > ,
340324 best_known_block_number : Option < T :: BlockNumber > ,
341- ) -> Result < ( Vec < LeafOf < T , I > > , primitives:: Proof < < T as Config < I > > :: Hash > ) , primitives:: Error > {
325+ ) -> Result < ( Vec < LeafOf < T , I > > , primitives:: Proof < HashOf < T , I > > ) , primitives:: Error > {
342326 // check whether best_known_block_number provided, else use current best block
343327 let best_known_block_number =
344328 best_known_block_number. unwrap_or_else ( || <frame_system:: Pallet < T > >:: block_number ( ) ) ;
@@ -359,7 +343,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
359343 }
360344
361345 /// Return the on-chain MMR root hash.
362- pub fn mmr_root ( ) -> < T as Config < I > > :: Hash {
346+ pub fn mmr_root ( ) -> HashOf < T , I > {
363347 Self :: mmr_root_hash ( )
364348 }
365349
@@ -371,7 +355,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
371355 /// or the proof is invalid.
372356 pub fn verify_leaves (
373357 leaves : Vec < LeafOf < T , I > > ,
374- proof : primitives:: Proof < < T as Config < I > > :: Hash > ,
358+ proof : primitives:: Proof < HashOf < T , I > > ,
375359 ) -> Result < ( ) , primitives:: Error > {
376360 if proof. leaf_count > Self :: mmr_leaves ( ) ||
377361 proof. leaf_count == 0 ||
0 commit comments