// Recover the node data from the database, only recover the real data, that is, the hash value
// of children or leaves
Recover the node data from the database, only recover the real data, that is, the hash value
of children or leaves
// Recover the node data from the database only recover the real data that is the hash value // of children or leaves
func (n *TreeNode) readFull(root []byte, adapter db.DataAdapter) error {
	if n == nil {
		return common.ErrNil
	}
	n.Reset()
	if len(root) == 0 || bytes.Compare(root, common.NilHashSlice) == 0 {
		return nil
	}
	content, err := adapter.Load(root)
	if err != nil {
		return err
	}
	if len(content) == 0 {
		return nil
	}
	loadEntire := false
	if content[0] == 0x1 {
		n.isLeaf = true
	} else if content[0] == 0x0 {
		n.isLeaf = false
	} else if content[0] == 0xff {
		loadEntire = true
	} else {
		return common.ErrIllegalStatus
	}
	buf := bytes.NewBuffer(content[1:])
	vr := rtl.NewValueReader(buf, 0)
	if loadEntire {
		sn := new(serialNode)
		if err = rtl.Decode(vr, sn); err != nil {
			return err
		}
		n.fromSerialNode(adapter, sn)
	} else {
		err = n.decodeDescendants(adapter, vr)
	}
	return err
}
func ( n * TreeNode ) readFull ( root [ ] byte , adapter db . DataAdapter ) error { if n == nil { return common . ErrNil } n . Reset ( ) if len ( root ) == 0 || bytes . Compare ( root , common . NilHashSlice ) == 0 { return nil } content , err := adapter . Load ( root ) if err != nil { return err } if len ( content ) == 0 { return nil } loadEntire := false if content [ 0 ] == 0x1 { n . isLeaf = true } else if content [ 0 ] == 0x0 { n . isLeaf = false } else if content [ 0 ] == 0xff { loadEntire = true } else { return common . ErrIllegalStatus } buf := bytes . NewBuffer ( content [ 1 : ] ) vr := rtl . NewValueReader ( buf , 0 ) if loadEntire { sn := new ( serialNode ) if err = rtl . Decode ( vr , sn ) ; err != nil { return err } n . fromSerialNode ( adapter , sn ) } else { err = n . decodeDescendants ( adapter , vr ) } return err }
Recover the node data from the database, only recover the real data, that is, the hash value
of children or leaves
Recover the node data from the database only recover the real data that is the hash value of children or leaves
// When the first byte is 0xff, it indicates that the content is the serialization of the // *serialNode; otherwise, it indicates that the content is only the value