// Swap sets a link pointing to the passed node as the value under the
// name key in this Shard or its children. It also returns the previous link
// under that name key (if any).
Swap sets a link pointing to the passed node as the value under the
name key in this Shard or its children. It also returns the previous link
under that name key (if any).
// Swap sets a link pointing to the passed node as the value under the // name key in this Shard or its children . It also returns the previous link // under that name key ( if any ) .
func (ds *Shard) Swap(ctx context.Context, name string, node ipld.Node) (*ipld.Link, error) {
	hv := newHashBits(name)
	err := ds.dserv.Add(ctx, node)
	if err != nil {
		return nil, err
	}
	lnk, err := ipld.MakeLink(node)
	if err != nil {
		return nil, err
	}
	lnk.Name = ds.linkNamePrefix(0) + name
	return ds.swapValue(ctx, hv, name, lnk)
}
func ( ds * Shard ) Swap ( ctx context . Context , name string , node ipld . Node ) ( * ipld . Link , error ) { hv := newHashBits ( name ) err := ds . dserv . Add ( ctx , node ) if err != nil { return nil , err } lnk , err := ipld . MakeLink ( node ) if err != nil { return nil , err } lnk . Name = ds . linkNamePrefix ( 0 ) + name return ds . swapValue ( ctx , hv , name , lnk ) }
Swap sets a link pointing to the passed node as the value under the
name key in this Shard or its children.
Swap sets a link pointing to the passed node as the value under the name key in this Shard or its children .
// FIXME: We don't need to set the name here, it will get overwritten. //  This is confusing, confirm and remove this line.