// Deserialization deserialize the node object from an io.Reader.
Deserialization deserialize the node object from an io.Reader.
// Deserialization deserialize the node object from an io . Reader .
func (n *node) Deserialization(r io.Reader) (shouldBeNil bool, err error) {
	if n == nil {
		return false, rtl.ErrDecodeIntoNil
	}
	header := new(NodeHeader)
	if _, err = header.Deserialization(r); err != nil {
		return
	}
	n.prefix = header.KeyToPrefix()
	if header.NT.HasChildren() {
		for i := 0; i < childrenLength; i++ {
			n.children[i] = nil
			if header.HasChild(i) {
				buf := make([]byte, common.HashLength)
				l, err := io.ReadFull(r, buf)
				if l == common.HashLength {
					n.children[i] = NewNodeWithFuncs(buf, n.generation, n.valueEncode, n.valueDecode, n.valueHasher, n.valueExpander)
					if err != nil {
						log.Warnf("ignored an error occurs when Deserialize node: %v", err)
					}
				} else if err != nil {
					return shouldBeNil, err
				}
			}
		}
	}
	if header.NT.HasValue() {
		buf := make([]byte, common.HashLength)
		l, err := io.ReadFull(r, buf)
		if l == common.HashLength {
			n.valuehash = buf
			if err != nil {
				log.Warnf("ignored an error occurs when Deserialize node: %v", err)
			}
		} else if err != nil {
			return shouldBeNil, err
		}
	}
	return false, nil
}
func ( n * node ) Deserialization ( r io . Reader ) ( shouldBeNil bool , err error ) { if n == nil { return false , rtl . ErrDecodeIntoNil } header := new ( NodeHeader ) if _ , err = header . Deserialization ( r ) ; err != nil { return } n . prefix = header . KeyToPrefix ( ) if header . NT . HasChildren ( ) { for i := 0 ; i < childrenLength ; i ++ { n . children [ i ] = nil if header . HasChild ( i ) { buf := make ( [ ] byte , common . HashLength ) l , err := io . ReadFull ( r , buf ) if l == common . HashLength { n . children [ i ] = NewNodeWithFuncs ( buf , n . generation , n . valueEncode , n . valueDecode , n . valueHasher , n . valueExpander ) if err != nil { log . Warnf ( " " , err ) } } else if err != nil { return shouldBeNil , err } } } } if header . NT . HasValue ( ) { buf := make ( [ ] byte , common . HashLength ) l , err := io . ReadFull ( r , buf ) if l == common . HashLength { n . valuehash = buf if err != nil { log . Warnf ( " " , err ) } } else if err != nil { return shouldBeNil , err } } return false , nil }
Deserialization deserialize the node object from an io.Reader.
Deserialization deserialize the node object from an io . Reader .
// decode NodeHeader object // decode prefix // decode children // read real child hashs // decode value