Skip to content

Commit

Permalink
Nits
Browse files Browse the repository at this point in the history
  • Loading branch information
thibault-martinez committed Sep 13, 2023
1 parent e787de9 commit 7c5471d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions sdk/src/types/block/slot/commitment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub struct SlotCommitment {
/// It is calculated based on genesis timestamp and the duration of a slot.
index: SlotIndex,
/// The commitment ID of the previous slot.
#[cfg_attr(feature = "serde", serde(rename = "prevId"))]
#[cfg_attr(feature = "serde", serde(rename = "previousCommitmentId"))]
previous_slot_commitment_id: SlotCommitmentId,
/// The digest of multiple sparse merkle tree roots of this slot.
roots_id: RootsId,
Expand Down Expand Up @@ -90,10 +90,11 @@ impl SlotCommitment {
pub fn id(&self) -> SlotCommitmentId {
let mut bytes = [0u8; SlotCommitmentId::LENGTH];
let mut packer = SlicePacker::new(&mut bytes);
let hash: [u8; 32] = Blake2b256::digest(self.pack_to_vec()).into();
let content = self.pack_to_vec();
let content_hash: [u8; 32] = Blake2b256::digest(content).into();

// PANIC: packing to an array of bytes can't fail.
hash.pack(&mut packer).unwrap();
content_hash.pack(&mut packer).unwrap();
self.index.pack(&mut packer).unwrap();

SlotCommitmentId::from(bytes)
Expand Down

0 comments on commit 7c5471d

Please sign in to comment.