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

11 years ago
11 years ago
11 years ago
10 years ago
11 years ago
11 years ago
10 years ago
11 years ago
11 years ago
11 years ago
  1. package merkle
  2. import (
  3. "fmt"
  4. )
  5. // Prints the in-memory children recursively.
  6. func PrintIAVLNode(node *IAVLNode) {
  7. fmt.Println("==== NODE")
  8. if node != nil {
  9. printIAVLNode(node, 0)
  10. }
  11. fmt.Println("==== END")
  12. }
  13. func printIAVLNode(node *IAVLNode, indent int) {
  14. indentPrefix := ""
  15. for i := 0; i < indent; i++ {
  16. indentPrefix += " "
  17. }
  18. if node.rightNode != nil {
  19. printIAVLNode(node.rightNode, indent+1)
  20. } else if node.rightHash != nil {
  21. fmt.Printf("%s %X\n", indentPrefix, node.rightHash)
  22. }
  23. fmt.Printf("%s%v:%v\n", indentPrefix, node.key, node.height)
  24. if node.leftNode != nil {
  25. printIAVLNode(node.leftNode, indent+1)
  26. } else if node.leftHash != nil {
  27. fmt.Printf("%s %X\n", indentPrefix, node.leftHash)
  28. }
  29. }
  30. func maxInt8(a, b int8) int8 {
  31. if a > b {
  32. return a
  33. }
  34. return b
  35. }