Example #1
0
// addNode adds the node to the graph + local storage
func addNode(n *core.IpfsNode, nd *dag.Node, fpath string) error {
	// add the file to the graph + local storage
	err := n.DAG.AddRecursive(nd)
	if err != nil {
		return err
	}

	u.POut("added %s\n", fpath)

	// ensure we keep it. atm no-op
	return n.PinDagNode(nd)
}
Example #2
0
func Pin(n *core.IpfsNode, args []string, opts map[string]interface{}, out io.Writer) error {
	for _, fn := range args {
		dagnode, err := n.Resolver.ResolvePath(fn)
		if err != nil {
			return fmt.Errorf("pin error: %v", err)
		}

		err = n.PinDagNode(dagnode)
		if err != nil {
			return fmt.Errorf("pin: %v", err)
		}
	}
	return nil
}