// switchToSharding returns a HAMT implementation of this directory.
switchToSharding returns a HAMT implementation of this directory.
// switchToSharding returns a HAMT implementation of this directory .
func (d *BasicDirectory) switchToSharding(ctx context.Context) (*HAMTDirectory, error) {
	hamtDir := new(HAMTDirectory)
	hamtDir.dserv = d.dserv
	shard, err := hamt.NewShard(d.dserv, DefaultShardWidth)
	if err != nil {
		return nil, err
	}
	shard.SetCidBuilder(d.node.CidBuilder())
	hamtDir.shard = shard
	for _, lnk := range d.node.Links() {
		node, err := d.dserv.Get(ctx, lnk.Cid)
		if err != nil {
			return nil, err
		}
		err = hamtDir.shard.Set(ctx, lnk.Name, node)
		if err != nil {
			return nil, err
		}
	}
	return hamtDir, nil
}
func ( d * BasicDirectory ) switchToSharding ( ctx context . Context ) ( * HAMTDirectory , error ) { hamtDir := new ( HAMTDirectory ) hamtDir . dserv = d . dserv shard , err := hamt . NewShard ( d . dserv , DefaultShardWidth ) if err != nil { return nil , err } shard . SetCidBuilder ( d . node . CidBuilder ( ) ) hamtDir . shard = shard for _ , lnk := range d . node . Links ( ) { node , err := d . dserv . Get ( ctx , lnk . Cid ) if err != nil { return nil , err } err = hamtDir . shard . Set ( ctx , lnk . Name , node ) if err != nil { return nil , err } } return hamtDir , nil }
switchToSharding returns a HAMT implementation of this directory.
switchToSharding returns a HAMT implementation of this directory .