refactor: return MmrPeaks from PartialMmr::peaks()

This commit is contained in:
Bobbin Threadbare
2023-12-21 01:00:52 -08:00
committed by Bobbin Threadbare
parent 59d93cb8ba
commit 4d0d8d3058
3 changed files with 28 additions and 12 deletions

View File

@@ -88,9 +88,11 @@ impl PartialMmr {
self.forest
}
// Returns a reference to the current peaks in the [PartialMmr]
pub fn peaks(&self) -> &[RpoDigest] {
&self.peaks
// Returns a reference to the current peaks in the [PartialMmr].
pub fn peaks(&self) -> MmrPeaks {
// expect() is OK here because the constructor ensures that MMR peaks can be constructed
// correctly
MmrPeaks::new(self.forest, self.peaks.clone()).expect("invalid MMR peaks")
}
/// Given a leaf position, returns the Merkle path to its corresponding peak. If the position