mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-28 12:07:57 +00:00
Forward port blake2 storage support (#2360)
* move storage maps to blake2_128 (#2268) * remove default hash, introduce twox_128 and blake2 * use blake2_128 & create ext_blake2_128 * refactor code * add benchmark * factorize generator * fix * parameterizable hasher * some fix * fix * fix * fix * metadata * fix * remove debug print * map -> blake2_256 * fix test * fix test * Apply suggestions from code review Co-Authored-By: thiolliere <gui.thiolliere@gmail.com> * impl twox 128 concat (#2353) * impl twox_128_concat * comment addressed * fix * impl twox_128->64_concat * fix test * Fix compilation and cleanup some docs * Apply suggestions from code review Co-Authored-By: bkchr <bkchr@users.noreply.github.com>
This commit is contained in:
committed by
Gavin Wood
parent
21d1ee4e99
commit
f0862606b7
@@ -17,16 +17,24 @@
|
||||
//! Hashable trait.
|
||||
|
||||
use crate::codec::Codec;
|
||||
use runtime_io::{blake2_256, twox_128, twox_256};
|
||||
use runtime_io::{blake2_128, blake2_256, twox_128, twox_256};
|
||||
use crate::storage::hashed::generator::StorageHasher;
|
||||
use crate::Twox64Concat;
|
||||
use crate::rstd::prelude::Vec;
|
||||
|
||||
/// Trait for available hash functions.
|
||||
// This trait must be kept coherent with srml-support-procedural HasherKind usage
|
||||
pub trait Hashable: Sized {
|
||||
fn blake2_128(&self) -> [u8; 16];
|
||||
fn blake2_256(&self) -> [u8; 32];
|
||||
fn twox_128(&self) -> [u8; 16];
|
||||
fn twox_256(&self) -> [u8; 32];
|
||||
fn twox_64_concat(&self) -> Vec<u8>;
|
||||
}
|
||||
|
||||
impl<T: Codec> Hashable for T {
|
||||
fn blake2_128(&self) -> [u8; 16] {
|
||||
self.using_encoded(blake2_128)
|
||||
}
|
||||
fn blake2_256(&self) -> [u8; 32] {
|
||||
self.using_encoded(blake2_256)
|
||||
}
|
||||
@@ -36,4 +44,7 @@ impl<T: Codec> Hashable for T {
|
||||
fn twox_256(&self) -> [u8; 32] {
|
||||
self.using_encoded(twox_256)
|
||||
}
|
||||
fn twox_64_concat(&self) -> Vec<u8> {
|
||||
self.using_encoded(Twox64Concat::hash)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user