github.com/turingchain2020/turingchain@v1.1.21/system/store/mavl/db/util.go (about)

     1  // Copyright Turing Corp. 2018 All Rights Reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package mavl
     6  
     7  import (
     8  	"fmt"
     9  	"strings"
    10  )
    11  
    12  // PrintNode the in-memory children recursively.
    13  func PrintNode(node *Node) {
    14  	fmt.Println("==== NODE")
    15  	if node != nil {
    16  		printNode(node, 0)
    17  	}
    18  	fmt.Println("==== END")
    19  }
    20  
    21  func printNode(node *Node, indent int) {
    22  	indentPrefix := strings.Repeat("  ", indent)
    23  	if node.rightNode != nil {
    24  		printNode(node.rightNode, indent+1)
    25  	}
    26  	fmt.Printf("%s|-%s:%03d\n", indentPrefix, string(node.key), node.height)
    27  	if node.leftNode != nil {
    28  		printNode(node.leftNode, indent+1)
    29  	}
    30  }
    31  
    32  func maxInt32(a, b int32) int32 {
    33  	if a > b {
    34  		return a
    35  	}
    36  	return b
    37  }