-
Notifications
You must be signed in to change notification settings - Fork 0
/
helper.go
51 lines (41 loc) · 834 Bytes
/
helper.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package merkle
import "fmt"
// helper functions for working with and debugging merkle
func printTree(n *Node, detailed bool) {
printed := false
fmt.Println("-----------------------------")
if n.isLeaf {
// fmt.Println("Leaf")
if !printed {
printed = true
fmt.Println(string(n.data))
if detailed {
// fmt.Println(string(n.Hash))
fmt.Println(string(n.Hex))
}
}
return
}
if n.Left != nil {
if !printed {
printed = true
fmt.Println(string(n.data))
if detailed {
// fmt.Println(string(n.Hash))
fmt.Println(string(n.Hex))
}
}
printTree(n.Left, detailed)
}
if n.Right != nil {
if !printed {
printed = true
fmt.Println(string(n.data))
if detailed {
// fmt.Println(string(n.Hash))
fmt.Println(string(n.Hex))
}
}
printTree(n.Right, detailed)
}
}