mirror of
https://github.com/ipfs/kubo.git
synced 2026-03-07 01:08:08 +08:00
cleaned up interface to use DAG
This commit is contained in:
parent
9f542f8797
commit
7b98bf80f4
@ -119,7 +119,7 @@ func addFile(n *core.IpfsNode, fpath string, depth int) (*dag.Node, error) {
|
||||
// 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
|
||||
k, err := n.AddDagNode(nd)
|
||||
k, err := n.DAG.Put(nd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@ -37,7 +37,7 @@ func catCmd(c *commander.Command, inp []string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
nd, err := n.GetDagNode(u.Key(h))
|
||||
nd, err := n.DAG.Get(u.Key(h))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@ -40,7 +40,7 @@ func lsCmd(c *commander.Command, inp []string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
nd, err := n.GetDagNode(u.Key(h))
|
||||
nd, err := n.DAG.Get(u.Key(h))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@ -58,7 +58,7 @@ func refCmd(c *commander.Command, inp []string) error {
|
||||
|
||||
var printRefs func(h mh.Multihash, recursive bool)
|
||||
printRefs = func(h mh.Multihash, recursive bool) {
|
||||
nd, err := n.GetDagNode(u.Key(h))
|
||||
nd, err := n.DAG.Get(u.Key(h))
|
||||
if err != nil {
|
||||
u.PErr("error: cannot retrieve %s (%s)\n", h.B58String(), err)
|
||||
return
|
||||
|
||||
@ -7,7 +7,6 @@ import (
|
||||
config "github.com/jbenet/go-ipfs/config"
|
||||
merkledag "github.com/jbenet/go-ipfs/merkledag"
|
||||
peer "github.com/jbenet/go-ipfs/peer"
|
||||
u "github.com/jbenet/go-ipfs/util"
|
||||
)
|
||||
|
||||
// IPFS Core module. It represents an IPFS instance.
|
||||
@ -74,11 +73,3 @@ func NewIpfsNode(cfg *config.Config) (*IpfsNode, error) {
|
||||
|
||||
return n, nil
|
||||
}
|
||||
|
||||
func (n *IpfsNode) AddDagNode(nd *merkledag.Node) (u.Key, error) {
|
||||
return n.DAG.Put(nd)
|
||||
}
|
||||
|
||||
func (n *IpfsNode) GetDagNode(k u.Key) (*merkledag.Node, error) {
|
||||
return n.DAG.Get(k)
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user