change HashFor to HashingFor (#14483)

* change HashFor to HashingFor

* fmt

* ".git/.scripts/commands/fmt/fmt.sh"

---------

Co-authored-by: command-bot <>
This commit is contained in:
Marijn Schouten
2023-07-25 18:24:14 +02:00
committed by GitHub
parent 00787a10e9
commit c9b54e10ff
26 changed files with 180 additions and 161 deletions
+14 -14
View File
@@ -25,7 +25,7 @@ use parking_lot::RwLock;
use sp_consensus::BlockOrigin;
use sp_core::offchain::OffchainStorage;
use sp_runtime::{
traits::{Block as BlockT, HashFor, NumberFor},
traits::{Block as BlockT, HashingFor, NumberFor},
Justification, Justifications, StateVersion, Storage,
};
use sp_state_machine::{
@@ -42,7 +42,7 @@ pub use sp_state_machine::{Backend as StateBackend, KeyValueStates};
pub type StateBackendFor<B, Block> = <B as Backend<Block>>::State;
/// Extracts the transaction for the given state backend.
pub type TransactionForSB<B, Block> = <B as StateBackend<HashFor<Block>>>::Transaction;
pub type TransactionForSB<B, Block> = <B as StateBackend<HashingFor<Block>>>::Transaction;
/// Extracts the transaction for the given backend.
pub type TransactionFor<B, Block> = TransactionForSB<StateBackendFor<B, Block>, Block>;
@@ -161,7 +161,7 @@ impl NewBlockState {
/// Keeps hold if the inserted block state and data.
pub trait BlockImportOperation<Block: BlockT> {
/// Associated state backend type.
type State: StateBackend<HashFor<Block>>;
type State: StateBackend<HashingFor<Block>>;
/// Returns pending state.
///
@@ -315,16 +315,16 @@ pub trait AuxStore {
/// An `Iterator` that iterates keys in a given block under a prefix.
pub struct KeysIter<State, Block>
where
State: StateBackend<HashFor<Block>>,
State: StateBackend<HashingFor<Block>>,
Block: BlockT,
{
inner: <State as StateBackend<HashFor<Block>>>::RawIter,
inner: <State as StateBackend<HashingFor<Block>>>::RawIter,
state: State,
}
impl<State, Block> KeysIter<State, Block>
where
State: StateBackend<HashFor<Block>>,
State: StateBackend<HashingFor<Block>>,
Block: BlockT,
{
/// Create a new iterator over storage keys.
@@ -361,7 +361,7 @@ where
impl<State, Block> Iterator for KeysIter<State, Block>
where
Block: BlockT,
State: StateBackend<HashFor<Block>>,
State: StateBackend<HashingFor<Block>>,
{
type Item = StorageKey;
@@ -373,17 +373,17 @@ where
/// An `Iterator` that iterates keys and values in a given block under a prefix.
pub struct PairsIter<State, Block>
where
State: StateBackend<HashFor<Block>>,
State: StateBackend<HashingFor<Block>>,
Block: BlockT,
{
inner: <State as StateBackend<HashFor<Block>>>::RawIter,
inner: <State as StateBackend<HashingFor<Block>>>::RawIter,
state: State,
}
impl<State, Block> Iterator for PairsIter<State, Block>
where
Block: BlockT,
State: StateBackend<HashFor<Block>>,
State: StateBackend<HashingFor<Block>>,
{
type Item = (StorageKey, StorageData);
@@ -397,7 +397,7 @@ where
impl<State, Block> PairsIter<State, Block>
where
State: StateBackend<HashFor<Block>>,
State: StateBackend<HashingFor<Block>>,
Block: BlockT,
{
/// Create a new iterator over storage key and value pairs.
@@ -506,11 +506,11 @@ pub trait Backend<Block: BlockT>: AuxStore + Send + Sync {
/// Associated blockchain backend type.
type Blockchain: BlockchainBackend<Block>;
/// Associated state backend type.
type State: StateBackend<HashFor<Block>>
type State: StateBackend<HashingFor<Block>>
+ Send
+ AsTrieBackend<
HashFor<Block>,
TrieBackendStorage = <Self::State as StateBackend<HashFor<Block>>>::TrieBackendStorage,
HashingFor<Block>,
TrieBackendStorage = <Self::State as StateBackend<HashingFor<Block>>>::TrieBackendStorage,
>;
/// Offchain workers local storage.
type OffchainStorage: OffchainStorage;
+9 -8
View File
@@ -25,7 +25,7 @@ use sp_core::{
};
use sp_runtime::{
generic::BlockId,
traits::{Block as BlockT, HashFor, Header as HeaderT, NumberFor, Zero},
traits::{Block as BlockT, HashingFor, Header as HeaderT, NumberFor, Zero},
Justification, Justifications, StateVersion, Storage,
};
use sp_state_machine::{
@@ -479,9 +479,10 @@ impl<Block: BlockT> backend::AuxStore for Blockchain<Block> {
/// In-memory operation.
pub struct BlockImportOperation<Block: BlockT> {
pending_block: Option<PendingBlock<Block>>,
old_state: InMemoryBackend<HashFor<Block>>,
new_state:
Option<<InMemoryBackend<HashFor<Block>> as StateBackend<HashFor<Block>>>::Transaction>,
old_state: InMemoryBackend<HashingFor<Block>>,
new_state: Option<
<InMemoryBackend<HashingFor<Block>> as StateBackend<HashingFor<Block>>>::Transaction,
>,
aux: Vec<(Vec<u8>, Option<Vec<u8>>)>,
finalized_blocks: Vec<(Block::Hash, Option<Justification>)>,
set_head: Option<Block::Hash>,
@@ -517,7 +518,7 @@ impl<Block: BlockT> BlockImportOperation<Block> {
}
impl<Block: BlockT> backend::BlockImportOperation<Block> for BlockImportOperation<Block> {
type State = InMemoryBackend<HashFor<Block>>;
type State = InMemoryBackend<HashingFor<Block>>;
fn state(&self) -> sp_blockchain::Result<Option<&Self::State>> {
Ok(Some(&self.old_state))
@@ -539,7 +540,7 @@ impl<Block: BlockT> backend::BlockImportOperation<Block> for BlockImportOperatio
fn update_db_storage(
&mut self,
update: <InMemoryBackend<HashFor<Block>> as StateBackend<HashFor<Block>>>::Transaction,
update: <InMemoryBackend<HashingFor<Block>> as StateBackend<HashingFor<Block>>>::Transaction,
) -> sp_blockchain::Result<()> {
self.new_state = Some(update);
Ok(())
@@ -606,7 +607,7 @@ impl<Block: BlockT> backend::BlockImportOperation<Block> for BlockImportOperatio
/// > **Warning**: Doesn't support all the features necessary for a proper database. Only use this
/// > struct for testing purposes. Do **NOT** use in production.
pub struct Backend<Block: BlockT> {
states: RwLock<HashMap<Block::Hash, InMemoryBackend<HashFor<Block>>>>,
states: RwLock<HashMap<Block::Hash, InMemoryBackend<HashingFor<Block>>>>,
blockchain: Blockchain<Block>,
import_lock: RwLock<()>,
pinned_blocks: RwLock<HashMap<Block::Hash, i64>>,
@@ -661,7 +662,7 @@ impl<Block: BlockT> backend::AuxStore for Backend<Block> {
impl<Block: BlockT> backend::Backend<Block> for Backend<Block> {
type BlockImportOperation = BlockImportOperation<Block>;
type Blockchain = Blockchain<Block>;
type State = InMemoryBackend<HashFor<Block>>;
type State = InMemoryBackend<HashingFor<Block>>;
type OffchainStorage = OffchainStorage;
fn begin_operation(&self) -> sp_blockchain::Result<Self::BlockImportOperation> {