I'm trying to get the length of hash. Currently, I tried to make use of len_bytes()
like in this docs. But I encountered an error like the below image.
Please help to solve this.! Thanks in advanced.
1 Answer
If your T::Hash
comes from frame_system::Config
here is the def:
/// The output of the `Hashing` function.
type Hash: Parameter
+ Member
+ MaybeSerializeDeserialize
+ Debug
+ MaybeDisplay
+ SimpleBitOps
+ Ord
+ Default
+ Copy
+ CheckEqual
+ sp_std::hash::Hash
+ AsRef<[u8]>
+ AsMut<[u8]>
+ MaybeMallocSizeOf
+ MaxEncodedLen;
Then you could simply do:
dna.as_ref().len()
T::Hash::len_bytes()
should work.Hash
type configured? what are you trying to achieve?(*dna).len_bytes()
T::Hash::len_bytes()
returns it.