You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

43 lines
810 B

package merkle
import (
"fmt"
)
// Prints the in-memory children recursively.
func PrintIAVLNode(node *IAVLNode) {
fmt.Println("==== NODE")
if node != nil {
printIAVLNode(node, 0)
}
fmt.Println("==== END")
}
func printIAVLNode(node *IAVLNode, indent int) {
indentPrefix := ""
for i := 0; i < indent; i++ {
indentPrefix += " "
}
if node.rightNode != nil {
printIAVLNode(node.rightNode, indent+1)
} else if node.rightHash != nil {
fmt.Printf("%s %X\n", indentPrefix, node.rightHash)
}
fmt.Printf("%s%v:%v\n", indentPrefix, node.key, node.height)
if node.leftNode != nil {
printIAVLNode(node.leftNode, indent+1)
} else if node.leftHash != nil {
fmt.Printf("%s %X\n", indentPrefix, node.leftHash)
}
}
func maxInt8(a, b int8) int8 {
if a > b {
return a
}
return b
}