mirror of
https://github.com/ipfs/kubo.git
synced 2025-05-20 16:36:46 +08:00

Also change existing 'Node' type to 'ProtoNode' and use that most everywhere for now. As we move forward with the integration we will try and use the Node interface in more places that we're currently using ProtoNode. License: MIT Signed-off-by: Jeromy <why@ipfs.io>
25 lines
509 B
Go
25 lines
509 B
Go
package coreunix
|
|
|
|
import (
|
|
"context"
|
|
|
|
core "github.com/ipfs/go-ipfs/core"
|
|
dag "github.com/ipfs/go-ipfs/merkledag"
|
|
path "github.com/ipfs/go-ipfs/path"
|
|
uio "github.com/ipfs/go-ipfs/unixfs/io"
|
|
)
|
|
|
|
func Cat(ctx context.Context, n *core.IpfsNode, pstr string) (*uio.DagReader, error) {
|
|
dagNode, err := core.Resolve(ctx, n, path.Path(pstr))
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
dnpb, ok := dagNode.(*dag.ProtoNode)
|
|
if !ok {
|
|
return nil, dag.ErrNotProtobuf
|
|
}
|
|
|
|
return uio.NewDagReader(ctx, dnpb, n.DAG)
|
|
}
|