1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-06-24 22:38:27 +08:00

removed old commands files

https://www.youtube.com/watch?v=kyFyAqLtHq8
This commit is contained in:
Juan Batiz-Benet
2014-11-18 02:35:36 -08:00
parent dc65e86e22
commit ad3f3e003f
46 changed files with 0 additions and 3168 deletions

View File

@ -1,65 +0,0 @@
package commands
import (
"io"
mh "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multihash"
"github.com/jbenet/go-ipfs/core"
mdag "github.com/jbenet/go-ipfs/merkledag"
u "github.com/jbenet/go-ipfs/util"
)
func Refs(n *core.IpfsNode, args []string, opts map[string]interface{}, out io.Writer) error {
unique, ok := opts["u"].(bool)
if !ok {
unique = false
}
recursive, ok := opts["r"].(bool)
if !ok {
recursive = false
}
var refsSeen map[u.Key]bool
if unique {
refsSeen = make(map[u.Key]bool)
}
for _, fn := range args {
nd, err := n.Resolver.ResolvePath(fn)
if err != nil {
return err
}
printRefs(n, nd, refsSeen, recursive)
}
return nil
}
func printRefs(n *core.IpfsNode, nd *mdag.Node, refSeen map[u.Key]bool, recursive bool) {
for _, link := range nd.Links {
printRef(link.Hash, refSeen)
if recursive {
nd, err := n.DAG.Get(u.Key(link.Hash))
if err != nil {
log.Errorf("error: cannot retrieve %s (%s)", link.Hash.B58String(), err)
return
}
printRefs(n, nd, refSeen, recursive)
}
}
}
func printRef(h mh.Multihash, refsSeen map[u.Key]bool) {
if refsSeen != nil {
_, found := refsSeen[u.Key(h)]
if found {
return
}
refsSeen[u.Key(h)] = true
}
u.POut("%s\n", h.B58String())
}