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.
 
 
 
 
 
 

48 lines
1002 B

package merkle
import (
"os"
"fmt"
)
func PrintIAVLNode(node *IAVLNode) {
fmt.Println("==== NODE")
printIAVLNode(node, 0)
fmt.Println("==== END")
}
func printIAVLNode(node *IAVLNode, indent int) {
indentPrefix := ""
for i:=0; i<indent; i++ {
indentPrefix += " "
}
if node == nil {
fmt.Printf("%s--\n", indentPrefix)
} else {
printIAVLNode(node.leftFilled(nil), indent+1)
fmt.Printf("%s%v:%v\n", indentPrefix, node.key, node.height)
printIAVLNode(node.rightFilled(nil), indent+1)
}
}
func randstr(length int) String {
if urandom, err := os.Open("/dev/urandom"); err != nil {
panic(err)
} else {
slice := make([]byte, length)
if _, err := urandom.Read(slice); err != nil {
panic(err)
}
urandom.Close()
return String(slice)
}
panic("unreachable")
}
func maxUint8(a, b uint8) uint8 {
if a > b {
return a
}
return b
}