Skip to content

Commit

Permalink
Add borsh and From<[u8;32]> to RootHash
Browse files Browse the repository at this point in the history
  • Loading branch information
preston-evans98 committed Sep 21, 2023
1 parent d8e5f4b commit 199ae1c
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,19 @@ pub type OwnedValue = alloc::vec::Vec<u8>;
use proptest_derive::Arbitrary;

/// A root of a [`JellyfishMerkleTree`].
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
#[derive(
Copy,
Clone,
PartialEq,
Eq,
PartialOrd,
Ord,
Hash,
Serialize,
Deserialize,
borsh::BorshSerialize,
borsh::BorshDeserialize,
)]
#[cfg_attr(any(test, feature = "fuzzing"), derive(Arbitrary))]
pub struct RootHash(pub [u8; 32]);

Expand All @@ -164,6 +176,12 @@ impl From<RootHash> for [u8; 32] {
}
}

impl From<[u8; 32]> for RootHash {
fn from(value: [u8; 32]) -> Self {
Self(value)
}
}

impl AsRef<[u8]> for RootHash {
fn as_ref(&self) -> &[u8] {
&self.0
Expand Down

0 comments on commit 199ae1c

Please sign in to comment.