1
1
package scorex .crypto .authds .avltree .batch
2
2
3
3
import scorex .crypto .authds .{Balance , _ }
4
- import scorex .crypto .encode .Base16
5
4
import scorex .crypto .hash .Digest
6
- import scorex .utils .{ ByteArray , ScryptoLogging }
5
+ import scorex .utils .ByteArray
7
6
8
7
import scala .collection .mutable .ArrayBuffer
9
8
import scala .util .{Failure , Success , Try }
@@ -13,7 +12,7 @@ import scala.util.{Failure, Success, Try}
13
12
* Code common to the prover and verifier of https://eprint.iacr.org/2016/994
14
13
* (see Appendix B, "Our Algorithms")
15
14
*/
16
- trait AuthenticatedTreeOps [D <: Digest ] extends BatchProofConstants with ScryptoLogging {
15
+ trait AuthenticatedTreeOps [D <: Digest ] extends BatchProofConstants with ToStringHelper {
17
16
18
17
type ChangeHappened = Boolean
19
18
type HeightIncreased = Boolean
@@ -39,17 +38,17 @@ trait AuthenticatedTreeOps[D <: Digest] extends BatchProofConstants with Scrypto
39
38
protected def onNodeVisit (n : Node [D ], operation : Operation , isRotate : Boolean = false ): Unit = {
40
39
n match {
41
40
case p : ProverNodes [D ] if collectChangedNodes && ! n.visited && ! p.isNew =>
42
- if (isRotate) {
43
- // during rotate operation node may stay in the tree in a different position
44
- changedNodesBufferToCheck += p
45
- } else if (operation.isInstanceOf [Insert ] || operation.isInstanceOf [Remove ]
46
- || operation.isInstanceOf [InsertOrUpdate ]) {
47
- // during non-rotate insert and remove operations nodes on the path should not be presented in a new tree
48
- changedNodesBuffer += p
49
- } else if (! operation.isInstanceOf [Lookup ]) {
50
- // during other non-lookup operations we don't know, whether node will stay in thee tree or not
51
- changedNodesBufferToCheck += p
52
- }
41
+ if (isRotate) {
42
+ // during rotate operation node may stay in the tree in a different position
43
+ changedNodesBufferToCheck += p
44
+ } else if (operation.isInstanceOf [Insert ] || operation.isInstanceOf [Remove ]
45
+ || operation.isInstanceOf [InsertOrUpdate ]) {
46
+ // during non-rotate insert and remove operations nodes on the path should not be presented in a new tree
47
+ changedNodesBuffer += p
48
+ } else if (! operation.isInstanceOf [Lookup ]) {
49
+ // during other non-lookup operations we don't know, whether node will stay in thee tree or not
50
+ changedNodesBufferToCheck += p
51
+ }
53
52
case _ =>
54
53
}
55
54
n.visited = true
@@ -382,7 +381,7 @@ trait AuthenticatedTreeOps[D <: Digest] extends BatchProofConstants with Scrypto
382
381
if (rightChild.balance < 0 ) {
383
382
// double left rotate
384
383
// I know rightChild.left is not a leaf, because rightChild has a higher subtree on the left
385
- onNodeVisit(rightChild.left, operation)
384
+ onNodeVisit(rightChild.left, operation, isRotate = true )
386
385
(doubleLeftRotate(newRoot, newLeft, rightChild), true )
387
386
} else {
388
387
// single left rotate
@@ -409,7 +408,7 @@ trait AuthenticatedTreeOps[D <: Digest] extends BatchProofConstants with Scrypto
409
408
if (leftChild.balance > 0 ) {
410
409
// double right rotate
411
410
// I know leftChild.right is not a leaf, because leftChild has a higher subtree on the right
412
- onNodeVisit(leftChild.right, operation)
411
+ onNodeVisit(leftChild.right, operation, isRotate = true )
413
412
(doubleRightRotate(r, leftChild, newRight), true )
414
413
} else {
415
414
// single right rotate
0 commit comments