Skip to content

Commit

Permalink
refac: Pull out root variable
Browse files Browse the repository at this point in the history
  • Loading branch information
jns-ps committed Oct 9, 2024
1 parent d1e1454 commit 59ebbd3
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions crates/common/src/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -551,25 +551,22 @@ where
}

fn get(&self, key: KeyHash) -> Result<HashchainResponse> {
let root = self.get_current_root()?.into();
let (value, proof) = self.jmt.get_with_proof(key, self.epoch)?;

match value {
Some(serialized_value) => {
let deserialized_value = Self::deserialize_value(&serialized_value)?;
let membership_proof = MembershipProof {
root: self.get_current_root()?.into(),
root,
proof,
key,
value: deserialized_value.clone(),
};
Ok(Found(deserialized_value, membership_proof))
}
None => {
let non_membership_proof = NonMembershipProof {
root: self.get_current_root()?.into(),
proof,
key,
};
let non_membership_proof = NonMembershipProof { root, proof, key };
Ok(NotFound(non_membership_proof))
}
}
Expand Down

0 comments on commit 59ebbd3

Please sign in to comment.