mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 07:01:05 +00:00
Reduce usage of Blake2Hasher (#5132)
This reduces the usage of `Blake2Hasher` in the code base and replaces it with `BlakeTwo256`. The most important change is the removal of the custom extern function for `Blake2Hasher`. The runtime `Hash` trait is now also simplified and directly requires that the implementing type implements `Hashable`.
This commit is contained in:
committed by
GitHub
parent
406fa981bb
commit
5a33228ea9
@@ -34,7 +34,7 @@ use sp_runtime::{
|
||||
Justification, BuildStorage,
|
||||
generic::{BlockId, SignedBlock, DigestItem},
|
||||
traits::{
|
||||
Block as BlockT, Header as HeaderT, Zero, NumberFor, HasherFor, SaturatedConversion, One,
|
||||
Block as BlockT, Header as HeaderT, Zero, NumberFor, HashFor, SaturatedConversion, One,
|
||||
DigestFor,
|
||||
},
|
||||
};
|
||||
@@ -120,7 +120,7 @@ impl <'a, State, Block> KeyIterator<'a, State, Block> {
|
||||
|
||||
impl<'a, State, Block> Iterator for KeyIterator<'a, State, Block> where
|
||||
Block: BlockT,
|
||||
State: StateBackend<HasherFor<Block>>,
|
||||
State: StateBackend<HashFor<Block>>,
|
||||
{
|
||||
type Item = StorageKey;
|
||||
|
||||
@@ -527,7 +527,7 @@ impl<B, E, Block, RA> Client<B, E, Block, RA> where
|
||||
Some(old_current_num)
|
||||
});
|
||||
let headers = cht_range.map(|num| self.block_hash(num));
|
||||
let proof = cht::build_proof::<Block::Header, HasherFor<Block>, _, _>(
|
||||
let proof = cht::build_proof::<Block::Header, HashFor<Block>, _, _>(
|
||||
cht_size,
|
||||
cht_num,
|
||||
std::iter::once(block_num),
|
||||
@@ -600,7 +600,7 @@ impl<B, E, Block, RA> Client<B, E, Block, RA> where
|
||||
zero: config_zero.clone(),
|
||||
end: config_end.map(|(config_end_number, _)| config_end_number),
|
||||
};
|
||||
let result_range: Vec<(NumberFor<Block>, u32)> = key_changes::<HasherFor<Block>, _>(
|
||||
let result_range: Vec<(NumberFor<Block>, u32)> = key_changes::<HashFor<Block>, _>(
|
||||
config_range,
|
||||
storage.storage(),
|
||||
range_first,
|
||||
@@ -654,12 +654,12 @@ impl<B, E, Block, RA> Client<B, E, Block, RA> where
|
||||
cht_size: NumberFor<Block>,
|
||||
) -> sp_blockchain::Result<ChangesProof<Block::Header>> {
|
||||
struct AccessedRootsRecorder<'a, Block: BlockT> {
|
||||
storage: &'a dyn ChangesTrieStorage<HasherFor<Block>, NumberFor<Block>>,
|
||||
storage: &'a dyn ChangesTrieStorage<HashFor<Block>, NumberFor<Block>>,
|
||||
min: NumberFor<Block>,
|
||||
required_roots_proofs: Mutex<BTreeMap<NumberFor<Block>, Block::Hash>>,
|
||||
};
|
||||
|
||||
impl<'a, Block: BlockT> ChangesTrieRootsStorage<HasherFor<Block>, NumberFor<Block>> for
|
||||
impl<'a, Block: BlockT> ChangesTrieRootsStorage<HashFor<Block>, NumberFor<Block>> for
|
||||
AccessedRootsRecorder<'a, Block>
|
||||
{
|
||||
fn build_anchor(&self, hash: Block::Hash)
|
||||
@@ -686,11 +686,11 @@ impl<B, E, Block, RA> Client<B, E, Block, RA> where
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, Block: BlockT> ChangesTrieStorage<HasherFor<Block>, NumberFor<Block>> for
|
||||
impl<'a, Block: BlockT> ChangesTrieStorage<HashFor<Block>, NumberFor<Block>> for
|
||||
AccessedRootsRecorder<'a, Block>
|
||||
{
|
||||
fn as_roots_storage(&self)
|
||||
-> &dyn sp_state_machine::ChangesTrieRootsStorage<HasherFor<Block>, NumberFor<Block>>
|
||||
-> &dyn sp_state_machine::ChangesTrieRootsStorage<HashFor<Block>, NumberFor<Block>>
|
||||
{
|
||||
self
|
||||
}
|
||||
@@ -734,7 +734,7 @@ impl<B, E, Block, RA> Client<B, E, Block, RA> where
|
||||
zero: config_zero,
|
||||
end: config_end.map(|(config_end_number, _)| config_end_number),
|
||||
};
|
||||
let proof_range = key_changes_proof::<HasherFor<Block>, _>(
|
||||
let proof_range = key_changes_proof::<HashFor<Block>, _>(
|
||||
config_range,
|
||||
&recording_storage,
|
||||
first_number,
|
||||
@@ -801,7 +801,7 @@ impl<B, E, Block, RA> Client<B, E, Block, RA> where
|
||||
.map(|block|
|
||||
block.and_then(|block| block.digest().log(DigestItem::as_changes_trie_root).cloned()))
|
||||
);
|
||||
let proof = cht::build_proof::<Block::Header, HasherFor<Block>, _, _>(
|
||||
let proof = cht::build_proof::<Block::Header, HashFor<Block>, _, _>(
|
||||
cht_size,
|
||||
cht_num,
|
||||
blocks,
|
||||
|
||||
Reference in New Issue
Block a user