Merge rust-bitcoin/rust-bitcoin#4123: hashes: Remove Clone trait bound from Tag
25707da14a
hashes: Remove Clone trait bound from Tag (ndungudedan) Pull request description: Resolves #4016 which was suggested here: https://github.com/rust-bitcoin/rust-bitcoin/pull/4010#discussion_r1942359979 ACKs for top commit: Kixunil: ACK25707da14a
tcharding: ACK25707da14a
Tree-SHA512: 1f1a5da4e3f40ba9ee0cd9e5dfa3924bfbb46e1f44e1d857e295bf768dff3407196211041e2a1d06c582d1dac6d7adb5c5aa0285300337504655ee72f2d0b9ec
This commit is contained in:
commit
217099a7b7
|
@ -10,7 +10,7 @@ use crate::sha256::Midstate;
|
|||
use crate::{sha256, HashEngine as _};
|
||||
|
||||
/// Trait representing a tag that can be used as a context for SHA256t hashes.
|
||||
pub trait Tag: Clone {
|
||||
pub trait Tag {
|
||||
/// The [`Midstate`] after pre-tagging the hash engine.
|
||||
const MIDSTATE: sha256::Midstate;
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ impl<T: Tag> core::hash::Hash for Hash<T> {
|
|||
crate::internal_macros::hash_trait_impls!(256, false, T: Tag);
|
||||
|
||||
/// Engine to compute SHA256t hash function.
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug)]
|
||||
pub struct HashEngine<T>(sha256::HashEngine, PhantomData<T>);
|
||||
|
||||
impl<T: Tag> Default for HashEngine<T> {
|
||||
|
@ -128,6 +128,12 @@ impl<T: Tag> Default for HashEngine<T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T: Tag> Clone for HashEngine<T> {
|
||||
fn clone(&self) -> Self {
|
||||
Self(self.0.clone(), PhantomData)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Tag> crate::HashEngine for HashEngine<T> {
|
||||
const BLOCK_SIZE: usize = 64; // Same as sha256::HashEngine::BLOCK_SIZE;
|
||||
fn input(&mut self, data: &[u8]) { self.0.input(data) }
|
||||
|
|
Loading…
Reference in New Issue