Skip to content

Commit 5e5f095

Browse files
committed
selfLabelOpt removed
1 parent 373debf commit 5e5f095

File tree

3 files changed

+5
-16
lines changed

3 files changed

+5
-16
lines changed

src/main/scala/scorex/crypto/authds/avltree/batch/BatchNode.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ sealed trait Node[D <: Digest] extends ToStringHelper {
1111

1212
protected var labelOpt: Option[D] = None
1313

14+
/**
15+
* Get digest of the node. If it was computed previously, read the digest from hash, otherwise, compute it.
16+
*/
1417
def label: D = labelOpt match {
1518
case None =>
1619
val l = computeLabel

src/main/scala/scorex/crypto/authds/avltree/batch/serialization/BatchAVLProverSerializer.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ class BatchAVLProverSerializer[D <: Digest, HF <: CryptographicHash[D]](implicit
134134
val key = ADKey @@ bytes.slice(2, keyLength + 2)
135135
val leftLabel = hf.byteArrayToDigest(bytes.slice(keyLength + 2, keyLength + 2 + labelLength)).get
136136
val rightLabel = hf.byteArrayToDigest(bytes.slice(keyLength + 2 + labelLength, keyLength + 2 + 2 * labelLength)).get
137-
new ProxyInternalNode[D](key, None, leftLabel, rightLabel, balance)
137+
new ProxyInternalNode[D](key, leftLabel, rightLabel, balance)
138138
case _ =>
139139
???
140140
}

src/main/scala/scorex/crypto/authds/avltree/batch/serialization/ProxyInternalNode.scala

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import scorex.crypto.hash.{CryptographicHash, Digest}
99
* Internal node for which not children are stored but just their digests
1010
*/
1111
class ProxyInternalNode[D <: Digest](protected var pk: ADKey,
12-
val selfLabelOpt: Option[D],
1312
val leftLabel: D,
1413
val rightLabel: D,
1514
protected var pb: Balance)
@@ -20,19 +19,6 @@ class ProxyInternalNode[D <: Digest](protected var pk: ADKey,
2019
hf.hash(Array(InternalNodePrefix, b), leftLabel, rightLabel)
2120
}
2221

23-
/**
24-
* Get digest of the node. If it was computed previously, read the digest from hash, otherwise,
25-
* take externally provided label or compute if not provided.
26-
*/
27-
override def label: D = labelOpt match {
28-
case Some(l) =>
29-
l
30-
case None =>
31-
val l = selfLabelOpt.getOrElse(computeLabel)
32-
labelOpt = Some(l)
33-
l
34-
}
35-
3622
private[serialization] def setChild(n: ProverNodes[D]): Unit = {
3723
if (n.label sameElements leftLabel) {
3824
l = n
@@ -53,6 +39,6 @@ class ProxyInternalNode[D <: Digest](protected var pk: ADKey,
5339

5440
object ProxyInternalNode {
5541
def apply[D <: Digest](node: InternalProverNode[D])(implicit phf: CryptographicHash[D]): ProxyInternalNode[D] = {
56-
new ProxyInternalNode[D](node.key, Some(node.label), node.left.label, node.right.label, node.balance)
42+
new ProxyInternalNode[D](node.key, node.left.label, node.right.label, node.balance)
5743
}
5844
}

0 commit comments

Comments
 (0)