Skip to content

Commit

Permalink
custom hashcode and comparison for ErgoHeader
Browse files Browse the repository at this point in the history
  • Loading branch information
kushti committed Jun 5, 2024
1 parent 1092b08 commit 0d6b2e0
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions data/shared/src/main/scala/org/ergoplatform/ErgoHeader.scala
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ case class ErgoHeader(override val version: ErgoHeader.Version,
override val unparsedBytes: Array[Byte],
_bytes: Array[Byte]) extends
HeaderWithoutPow(version, parentId, ADProofsRoot, stateRoot, transactionsRoot, timestamp,
nBits, height, extensionRoot, votes, unparsedBytes) {
nBits, height, extensionRoot, votes, unparsedBytes) {

lazy val bytes = if (_bytes != null) {
lazy val bytes = if(_bytes != null) {
_bytes
} else {
ErgoHeader.sigmaSerializer.toBytes(this)
Expand All @@ -116,6 +116,12 @@ case class ErgoHeader(override val version: ErgoHeader.Version,

lazy val id = Colls.fromArray(serializedId)

override def hashCode(): Int = id.hashCode()

override def equals(other: Any): Boolean = other match {
case h: ErgoHeader => h.id == this.id
case _ => false
}
}


Expand Down

0 comments on commit 0d6b2e0

Please sign in to comment.