Skip to content

Commit 6611b0c

Browse files
committed
perf: move position lookup before merkle tree build
1 parent 2fc54bc commit 6611b0c

File tree

1 file changed

+4
-2
lines changed
  • batcher/aligned-sdk/src/aggregation_layer

1 file changed

+4
-2
lines changed

batcher/aligned-sdk/src/aggregation_layer/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,15 @@ pub async fn check_proof_verification(
6363
.await?;
6464

6565
let leaves: Vec<Hash32> = leaves.iter().map(|leaf| Hash32(*leaf)).collect();
66-
let Some(merkle_tree) = MerkleTree::<Hash32>::build(&leaves) else {
66+
67+
let Some(pos) = leaves.iter().position(|p| p.0 == proof_commitment) else {
6768
continue;
6869
};
6970

70-
let Some(pos) = leaves.iter().position(|p| p.0 == proof_commitment) else {
71+
let Some(merkle_tree) = MerkleTree::<Hash32>::build(&leaves) else {
7172
continue;
7273
};
74+
7375
let Some(proof) = merkle_tree.get_proof_by_pos(pos) else {
7476
continue;
7577
};

0 commit comments

Comments
 (0)