// When value is a legal hash value, a new leaf node is generated. Otherwise, when the
// child is not nil, a new non leaf node is generated.
When value is a legal hash value, a new leaf node is generated. Otherwise, when the
child is not nil, a new non leaf node is generated.
// When value is a legal hash value a new leaf node is generated . Otherwise when the // child is not nil a new non leaf node is generated .
func NewNodeByProof(adapter db.DataAdapter, index int, value []byte, child *TreeNode,
	proof *common.MerkleProofs) (rn *TreeNode, err error) {
	if index < 0 || index >= childrenLength ||
		(len(value) != common.HashLength && child == nil) ||
		proof == nil || proof.Len() != ValueKeyLength {
		return nil, common.ErrIllegalParams
	}
	node := &TreeNode{
		isLeaf:  len(value) == common.HashLength, 
		Branchs: make(map[string][]byte),
	}
	if err := node.MergeProof(adapter, index, value, child, proof); err != nil {
		return nil, err
	}
	return node, nil
}
func NewNodeByProof ( adapter db . DataAdapter , index int , value [ ] byte , child * TreeNode , proof * common . MerkleProofs ) ( rn * TreeNode , err error ) { if index < 0 || index >= childrenLength || ( len ( value ) != common . HashLength && child == nil ) || proof == nil || proof . Len ( ) != ValueKeyLength { return nil , common . ErrIllegalParams } node := & TreeNode { isLeaf : len ( value ) == common . HashLength , Branchs : make ( map [ string ] [ ] byte ) , } if err := node . MergeProof ( adapter , index , value , child , proof ) ; err != nil { return nil , err } return node , nil }
When value is a legal hash value, a new leaf node is generated.
When value is a legal hash value a new leaf node is generated .
// If value is a legal hash value, it is a leaf node