Skip to content

Commit c611b13

Browse files
committed
Batch Merkle Proof - override equals for matcher array equality
1 parent 2237785 commit c611b13

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/main/scala/scorex/crypto/authds/merkle/BatchMerkleProof.scala

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import scorex.crypto.authds.merkle.MerkleTree.InternalNodePrefix
55
import scorex.crypto.hash.{CryptographicHash, Digest}
66
import scorex.util.ScorexEncoding
77

8+
import java.util
89
import scala.language.postfixOps
910

1011
/**
@@ -92,4 +93,15 @@ case class BatchMerkleProof[D <: Digest](indices: Seq[(Int, Digest)], proofs: Se
9293
val e = indices sortBy(_._1)
9394
loop(indices.map(_._1), e, proofs).head.sameElements(expectedRootHash)
9495
}
96+
97+
override def equals(obj: Any): Boolean = obj match {
98+
case that: BatchMerkleProof[D] =>
99+
(this.indices zip that.indices forall { case (left, right) =>
100+
left._1 == right._1 && util.Arrays.equals(left._2, right._2)
101+
}) &&
102+
(this.proofs zip that.proofs forall { case (left, right) =>
103+
util.Arrays.equals(left._1, right._1) && left._2 == right._2
104+
})
105+
case _ => false
106+
}
95107
}

0 commit comments

Comments
 (0)