mirror of
https://github.com/ipfs/kubo.git
synced 2025-05-20 08:27:29 +08:00

* Most of our datastores barf on non []byte values. * We have to have a bunch of "is this a []byte" checks. * Saves some allocations. License: MIT Signed-off-by: Steven Allen <steven@stebalien.com>
25 lines
638 B
Go
25 lines
638 B
Go
package coreunix
|
|
|
|
import (
|
|
"context"
|
|
|
|
core "github.com/ipfs/go-ipfs/core"
|
|
path "gx/ipfs/QmV1W98rBAovVJGkeYHfqJ19JdT9dQbbWsCq9zPaMyrxYx/go-path"
|
|
resolver "gx/ipfs/QmV1W98rBAovVJGkeYHfqJ19JdT9dQbbWsCq9zPaMyrxYx/go-path/resolver"
|
|
uio "gx/ipfs/QmagwbbPqiN1oa3SDMZvpTFE5tNuegF1ULtuJvA9EVzsJv/go-unixfs/io"
|
|
)
|
|
|
|
func Cat(ctx context.Context, n *core.IpfsNode, pstr string) (uio.DagReader, error) {
|
|
r := &resolver.Resolver{
|
|
DAG: n.DAG,
|
|
ResolveOnce: uio.ResolveUnixfsOnce,
|
|
}
|
|
|
|
dagNode, err := core.Resolve(ctx, n.Namesys, r, path.Path(pstr))
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return uio.NewDagReader(ctx, dagNode, n.DAG)
|
|
}
|