Skip to content

Commit

Permalink
apply
Browse files Browse the repository at this point in the history
  • Loading branch information
rkdud007 committed Jan 22, 2024
1 parent 61d5bf5 commit e87018e
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/mmr/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,10 @@ impl MMR {
}

let options = options.unwrap_or_default();
let element_count = self.elements_count.get().await?;
let tree_size = options.elements_count.unwrap_or(element_count);
let tree_size = match options.elements_count {
Some(count) => count,
None => self.elements_count.get().await?,
};

if element_index > tree_size {
return Err(MMRError::InvalidElementIndex);
Expand Down Expand Up @@ -284,10 +286,9 @@ impl MMR {
options: Option<ProofOptions>,
) -> Result<Vec<Proof>, MMRError> {
let options = options.unwrap_or_default();
let tree_size = if let Some(count) = options.elements_count {
count
} else {
self.elements_count.get().await?
let tree_size = match options.elements_count {
Some(count) => count,
None => self.elements_count.get().await?,
};

for &element_index in &elements_indexes {
Expand Down Expand Up @@ -352,8 +353,10 @@ impl MMR {
options: Option<ProofOptions>,
) -> Result<bool, MMRError> {
let options = options.unwrap_or_default();
let element_count = self.elements_count.get().await?;
let tree_size = options.elements_count.unwrap_or(element_count);
let tree_size = match options.elements_count {
Some(count) => count,
None => self.elements_count.get().await?,
};

let leaf_count = mmr_size_to_leaf_count(tree_size);
let peaks_count = leaf_count_to_peaks_count(leaf_count);
Expand Down

0 comments on commit e87018e

Please sign in to comment.