refactor: define trait HashOutput for some Hash associate type (#14220)

* define trait `HashOutput`

* improve

* improve

* Update primitives/runtime/src/traits.rs

Co-authored-by: Bastian Köcher <git@kchr.de>

* remove `Block::Hash: Ord`

* fmt

* add `MaybeFromStr`

* cleanup

* fix

* remove useless `HashOutput`

---------

Co-authored-by: Bastian Köcher <git@kchr.de>
This commit is contained in:
yjh
2023-06-08 10:02:13 +08:00
committed by GitHub
parent c31c6a1a73
commit ddb46a8aa0
19 changed files with 85 additions and 146 deletions
+2 -8
View File
@@ -423,10 +423,7 @@ impl<B: BlockT> StateBackend<HashFor<B>> for BenchmarkingState<B> {
&self,
delta: impl Iterator<Item = (&'a [u8], Option<&'a [u8]>)>,
state_version: StateVersion,
) -> (B::Hash, Self::Transaction)
where
B::Hash: Ord,
{
) -> (B::Hash, Self::Transaction) {
self.state
.borrow()
.as_ref()
@@ -438,10 +435,7 @@ impl<B: BlockT> StateBackend<HashFor<B>> for BenchmarkingState<B> {
child_info: &ChildInfo,
delta: impl Iterator<Item = (&'a [u8], Option<&'a [u8]>)>,
state_version: StateVersion,
) -> (B::Hash, bool, Self::Transaction)
where
B::Hash: Ord,
{
) -> (B::Hash, bool, Self::Transaction) {
self.state
.borrow()
.as_ref()
+2 -8
View File
@@ -243,10 +243,7 @@ impl<B: BlockT> StateBackend<HashFor<B>> for RefTrackingState<B> {
&self,
delta: impl Iterator<Item = (&'a [u8], Option<&'a [u8]>)>,
state_version: StateVersion,
) -> (B::Hash, Self::Transaction)
where
B::Hash: Ord,
{
) -> (B::Hash, Self::Transaction) {
self.state.storage_root(delta, state_version)
}
@@ -255,10 +252,7 @@ impl<B: BlockT> StateBackend<HashFor<B>> for RefTrackingState<B> {
child_info: &ChildInfo,
delta: impl Iterator<Item = (&'a [u8], Option<&'a [u8]>)>,
state_version: StateVersion,
) -> (B::Hash, bool, Self::Transaction)
where
B::Hash: Ord,
{
) -> (B::Hash, bool, Self::Transaction) {
self.state.child_storage_root(child_info, delta, state_version)
}
@@ -171,10 +171,7 @@ impl<S: StateBackend<HashFor<B>>, B: BlockT> StateBackend<HashFor<B>> for Record
&self,
delta: impl Iterator<Item = (&'a [u8], Option<&'a [u8]>)>,
state_version: StateVersion,
) -> (B::Hash, Self::Transaction)
where
B::Hash: Ord,
{
) -> (B::Hash, Self::Transaction) {
self.state.storage_root(delta, state_version)
}
@@ -183,10 +180,7 @@ impl<S: StateBackend<HashFor<B>>, B: BlockT> StateBackend<HashFor<B>> for Record
child_info: &ChildInfo,
delta: impl Iterator<Item = (&'a [u8], Option<&'a [u8]>)>,
state_version: StateVersion,
) -> (B::Hash, bool, Self::Transaction)
where
B::Hash: Ord,
{
) -> (B::Hash, bool, Self::Transaction) {
self.state.child_storage_root(child_info, delta, state_version)
}