Removes unnecessary blank impl for Backend (#8897)

* Removes unnecessary blank impl for Backend

This commit removes a from my perspective unneccessary implementation
for &T which implement Backend.

The current implementation exists (again from my perspective) solely
to satisfy a methods &mut self parameters (i.e. allows to satisfy
this for an & reference via using &mut &Backend).

As all implementors use a RefCell with borrow_mut() where actually
calling the mentioned &mut self method and then forwad to the
{} implementation of either TrieBackend or ProvingBackend, the
current &mut self seems to be not needed.

* Fixed tests client
This commit is contained in:
Frederik Schulz
2021-05-25 21:50:12 +02:00
committed by GitHub
parent ec409615a3
commit ad76ac798e
10 changed files with 12 additions and 92 deletions
+1 -1
View File
@@ -507,7 +507,7 @@ impl<B: BlockT> StateBackend<HashFor<B>> for BenchmarkingState<B> {
*self.whitelist.borrow_mut() = new;
}
fn register_overlay_stats(&mut self, stats: &sp_state_machine::StateMachineStats) {
fn register_overlay_stats(&self, stats: &sp_state_machine::StateMachineStats) {
self.state.borrow_mut().as_mut().map(|s| s.register_overlay_stats(stats));
}
+1 -1
View File
@@ -259,7 +259,7 @@ impl<B: BlockT> StateBackend<HashFor<B>> for RefTrackingState<B> {
self.state.as_trie_backend()
}
fn register_overlay_stats(&mut self, stats: &StateMachineStats) {
fn register_overlay_stats(&self, stats: &StateMachineStats) {
self.state.register_overlay_stats(stats);
}
+2 -2
View File
@@ -677,7 +677,7 @@ impl<S: StateBackend<HashFor<B>>, B: BlockT> StateBackend<HashFor<B>> for Cachin
self.state.as_trie_backend()
}
fn register_overlay_stats(&mut self, stats: &sp_state_machine::StateMachineStats) {
fn register_overlay_stats(&self, stats: &sp_state_machine::StateMachineStats) {
self.overlay_stats.add(stats);
}
@@ -862,7 +862,7 @@ impl<S: StateBackend<HashFor<B>>, B: BlockT> StateBackend<HashFor<B>> for Syncin
.as_trie_backend()
}
fn register_overlay_stats(&mut self, stats: &sp_state_machine::StateMachineStats) {
fn register_overlay_stats(&self, stats: &sp_state_machine::StateMachineStats) {
self.caching_state().register_overlay_stats(stats);
}
+1 -1
View File
@@ -526,7 +526,7 @@ impl<H: Hasher> StateBackend<H> for GenesisOrUnavailableState<H>
}
}
fn register_overlay_stats(&mut self, _stats: &sp_state_machine::StateMachineStats) { }
fn register_overlay_stats(&self, _stats: &sp_state_machine::StateMachineStats) { }
fn usage_info(&self) -> sp_state_machine::UsageInfo {
sp_state_machine::UsageInfo::empty()
@@ -220,7 +220,7 @@ where
Box::new(sp_state_machine::ExecutionError::UnableToGenerateProof) as Box<dyn sp_state_machine::Error>
)?;
let state_runtime_code = sp_state_machine::backend::BackendRuntimeCode::new(&trie_state);
let state_runtime_code = sp_state_machine::backend::BackendRuntimeCode::new(trie_state);
// It is important to extract the runtime code here before we create the proof
// recorder.
let runtime_code = state_runtime_code.runtime_code()
@@ -167,7 +167,7 @@ fn construct_block(
};
let hash = header.hash();
let mut overlay = OverlayedChanges::default();
let backend_runtime_code = sp_state_machine::backend::BackendRuntimeCode::new(&backend);
let backend_runtime_code = sp_state_machine::backend::BackendRuntimeCode::new(backend);
let runtime_code = backend_runtime_code.runtime_code().expect("Code is part of the backend");
let task_executor = Box::new(TaskExecutor::new());