BlockHash: Move Encodable and Decodable trait impls
What changed, and why it matters
This commit simply reorders two blocks of code in a single Rust source file. It moves the implementation of the Decodable trait for BlockHash to appear earlier in the file, before the definition of its helper decoder type. The commit message and the diff confirm there is no change to program logic, behavior, or security.
No security action needed. Treat as a normal refactoring/reordering commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
In primitives/src/hash_types/block_hash.rs, the impl encoding::Decodable for BlockHash block is moved from after the BlockHashDecoder struct and its impl encoding::Decoder to before them. The Encodable impl is already first and unchanged. No tokens are modified, added, or removed beyond the move; the diff shows +5/-5 for the relocated block. This is a pure code organization change with no functional effect.
Changed components
primitives/src/hash_types/block_hash.rsInspect captured patch +5 / −5
diff --git a/primitives/src/hash_types/block_hash.rs b/primitives/src/hash_types/block_hash.rs
index b419986a..b23fff5b 100644
--- a/primitives/src/hash_types/block_hash.rs
+++ b/primitives/src/hash_types/block_hash.rs
@@ -43,6 +43,11 @@ impl Encodable for BlockHash {
}
}
+impl encoding::Decodable for BlockHash {
+ type Decoder = BlockHashDecoder;
+ fn decoder() -> Self::Decoder { BlockHashDecoder(encoding::ArrayDecoder::<32>::new()) }
+}
+
/// The decoder for the [`BlockHash`] type.
pub struct BlockHashDecoder(encoding::ArrayDecoder<32>);
@@ -74,11 +79,6 @@ impl encoding::Decoder for BlockHashDecoder {
fn read_limit(&self) -> usize { self.0.read_limit() }
}
-impl encoding::Decodable for BlockHash {
- type Decoder = BlockHashDecoder;
- fn decoder() -> Self::Decoder { BlockHashDecoder(encoding::ArrayDecoder::<32>::new()) }
-}
-
/// An error consensus decoding an `BlockHash`.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct BlockHashDecoderError(encoding::UnexpectedEofError);
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.