Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
fixed some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Wizdave97 committed Jan 10, 2022
1 parent af1313e commit 3a97c5f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 15 deletions.
15 changes: 4 additions & 11 deletions bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1613,17 +1613,10 @@ impl_runtime_apis! {
fn verify_proof(leaves: Vec<mmr::EncodableOpaqueLeaf>, proof: mmr::Proof<mmr::Hash>)
-> Result<(), mmr::Error>
{
let leaves = {
let mut decoded_leaves = Vec::new();
for l in &leaves {
let leaf: mmr::Leaf = l.clone()
.into_opaque_leaf()
.try_decode()
.ok_or(mmr::Error::Verify)?;
decoded_leaves.push(leaf);
}
decoded_leaves
};
let leaves = leaves.into_iter().map(|leaf|
leaf.into_opaque_leaf()
.try_decode()
.ok_or(mmr::Error::Verify)).collect::<Result<Vec<mmr::Leaf>, mmr::Error>>()?;

Mmr::verify_leaves(leaves, proof)
}
Expand Down
8 changes: 4 additions & 4 deletions frame/merkle-mountain-range/src/mmr/mmr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ where
);

let mut verification_result = Ok(false);
let is_valid = leaves.iter().all(|leaf| {
let is_valid = leaves.into_iter().all(|leaf| {
let mut res = false;
for pos in &positions {
match p.verify(Node::Hash(root.clone()), vec![(*pos, leaf.clone())]) {
match p.verify(Node::Hash(root.clone()), vec![(*pos, leaf)]) {
Ok(val) => {
res = val;
break
Expand Down Expand Up @@ -122,10 +122,10 @@ where
let root = self.mmr.get_root().map_err(|e| Error::GetRoot.log_error(e))?;
let mut verification_result = Ok(false);

let is_valid = leaves.iter().all(|leaf| {
let is_valid = leaves.into_iter().all(|leaf| {
let mut res = false;
for pos in &positions {
match p.verify(root.clone(), vec![(*pos, Node::Data(leaf.clone()))]) {
match p.verify(root.clone(), vec![(*pos, Node::Data(leaf))]) {
Ok(val) => {
res = val;
break
Expand Down

0 comments on commit 3a97c5f

Please sign in to comment.