// NewHamtFromDag creates new a HAMT shard from the given DAG.
NewHamtFromDag creates new a HAMT shard from the given DAG.
// NewHamtFromDag creates new a HAMT shard from the given DAG .
func NewHamtFromDag(dserv ipld.DAGService, nd ipld.Node) (*Shard, error) {
	pbnd, ok := nd.(*dag.ProtoNode)
	if !ok {
		return nil, dag.ErrNotProtobuf
	}
	fsn, err := format.FSNodeFromBytes(pbnd.Data())
	if err != nil {
		return nil, err
	}
	if fsn.Type() != format.THAMTShard {
		return nil, fmt.Errorf("node was not a dir shard")
	}
	if fsn.HashType() != HashMurmur3 {
		return nil, fmt.Errorf("only murmur3 supported as hash function")
	}
	size := int(fsn.Fanout())
	ds, err := makeShard(dserv, size)
	if err != nil {
		return nil, err
	}
	ds.childer.makeChilder(fsn.Data(), pbnd.Links())
	ds.hashFunc = fsn.HashType()
	ds.builder = pbnd.CidBuilder()
	return ds, nil
}
func NewHamtFromDag ( dserv ipld . DAGService , nd ipld . Node ) ( * Shard , error ) { pbnd , ok := nd . ( * dag . ProtoNode ) if ! ok { return nil , dag . ErrNotProtobuf } fsn , err := format . FSNodeFromBytes ( pbnd . Data ( ) ) if err != nil { return nil , err } if fsn . Type ( ) != format . THAMTShard { return nil , fmt . Errorf ( " " ) } if fsn . HashType ( ) != HashMurmur3 { return nil , fmt . Errorf ( " " ) } size := int ( fsn . Fanout ( ) ) ds , err := makeShard ( dserv , size ) if err != nil { return nil , err } ds . childer . makeChilder ( fsn . Data ( ) , pbnd . Links ( ) ) ds . hashFunc = fsn . HashType ( ) ds . builder = pbnd . CidBuilder ( ) return ds , nil }
NewHamtFromDag creates new a HAMT shard from the given DAG.
NewHamtFromDag creates new a HAMT shard from the given DAG .