use old go-path
This commit is contained in:
+11
-9
@@ -17,15 +17,11 @@ import (
|
||||
|
||||
"github.com/ipfs/go-blockservice"
|
||||
"github.com/ipfs/go-cid"
|
||||
bsfetcher "github.com/ipfs/go-fetcher/impl/blockservice"
|
||||
offline "github.com/ipfs/go-ipfs-exchange-offline"
|
||||
cbor "github.com/ipfs/go-ipld-cbor"
|
||||
ipld "github.com/ipfs/go-ipld-format"
|
||||
logging "github.com/ipfs/go-log/v2"
|
||||
"github.com/ipfs/go-merkledag"
|
||||
"github.com/ipfs/go-path"
|
||||
"github.com/ipfs/go-path/resolver"
|
||||
cidlink "github.com/ipld/go-ipld-prime/linking/cid"
|
||||
mh "github.com/multiformats/go-multihash"
|
||||
cbg "github.com/whyrusleeping/cbor-gen"
|
||||
|
||||
@@ -38,6 +34,8 @@ import (
|
||||
"github.com/filecoin-project/lotus/chain/store"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
"github.com/filecoin-project/lotus/chain/vm"
|
||||
"github.com/filecoin-project/lotus/lib/oldpath"
|
||||
"github.com/filecoin-project/lotus/lib/oldpath/oldresolver"
|
||||
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
||||
)
|
||||
|
||||
@@ -552,23 +550,27 @@ func resolveOnce(bs blockstore.Blockstore, tse stmgr.Executor) func(ctx context.
|
||||
}
|
||||
|
||||
func (a *ChainAPI) ChainGetNode(ctx context.Context, p string) (*api.IpldObject, error) {
|
||||
ip, err := path.ParsePath(p)
|
||||
ip, err := oldpath.ParsePath(p)
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("parsing path: %w", err)
|
||||
}
|
||||
|
||||
bs := a.ExposedBlockstore
|
||||
bsvc := blockservice.New(bs, offline.Exchange(bs))
|
||||
fc := bsfetcher.NewFetcherConfig(bsvc)
|
||||
r := resolver.NewBasicResolver(fc)
|
||||
dag := merkledag.NewDAGService(bsvc)
|
||||
|
||||
node, lnk, err := r.ResolvePath(ctx, ip)
|
||||
r := &oldresolver.Resolver{
|
||||
DAG: dag,
|
||||
ResolveOnce: resolveOnce(bs, a.TsExec),
|
||||
}
|
||||
|
||||
node, err := r.ResolvePath(ctx, ip)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &api.IpldObject{
|
||||
Cid: lnk.(cidlink.Link).Cid,
|
||||
Cid: node.Cid(),
|
||||
Obj: node,
|
||||
}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user