Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
a4cb0602
提交
a4cb0602
authored
10月 15, 2018
作者:
Łukasz Magiera
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
coreapi unixfs: use session for resolving too
License: MIT Signed-off-by:
Łukasz Magiera
<
magik6k@gmail.com
>
上级
faf5230e
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
17 行增加
和
8 行删除
+17
-8
coreapi.go
core/coreapi/coreapi.go
+3
-1
path.go
core/coreapi/path.go
+9
-3
unixfs.go
core/coreapi/unixfs.go
+5
-4
没有找到文件。
core/coreapi/coreapi.go
浏览文件 @
a4cb0602
...
@@ -18,17 +18,19 @@ import (
...
@@ -18,17 +18,19 @@ import (
coreiface
"github.com/ipfs/go-ipfs/core/coreapi/interface"
coreiface
"github.com/ipfs/go-ipfs/core/coreapi/interface"
logging
"gx/ipfs/QmZChCsSt8DctjceaL56Eibc29CVQq4dGKRXC5JRZ6Ppae/go-log"
logging
"gx/ipfs/QmZChCsSt8DctjceaL56Eibc29CVQq4dGKRXC5JRZ6Ppae/go-log"
ipld
"gx/ipfs/QmdDXJs4axxefSPgK6Y1QhpJWKuDPnGJiqgq4uncb4rFHL/go-ipld-format"
)
)
var
log
=
logging
.
Logger
(
"core/coreapi"
)
var
log
=
logging
.
Logger
(
"core/coreapi"
)
type
CoreAPI
struct
{
type
CoreAPI
struct
{
node
*
core
.
IpfsNode
node
*
core
.
IpfsNode
dag
ipld
.
DAGService
}
}
// NewCoreAPI creates new instance of IPFS CoreAPI backed by go-ipfs Node.
// NewCoreAPI creates new instance of IPFS CoreAPI backed by go-ipfs Node.
func
NewCoreAPI
(
n
*
core
.
IpfsNode
)
coreiface
.
CoreAPI
{
func
NewCoreAPI
(
n
*
core
.
IpfsNode
)
coreiface
.
CoreAPI
{
api
:=
&
CoreAPI
{
n
}
api
:=
&
CoreAPI
{
n
,
n
.
DAG
}
return
api
return
api
}
}
...
...
core/coreapi/path.go
浏览文件 @
a4cb0602
...
@@ -7,12 +7,13 @@ import (
...
@@ -7,12 +7,13 @@ import (
"github.com/ipfs/go-ipfs/core"
"github.com/ipfs/go-ipfs/core"
coreiface
"github.com/ipfs/go-ipfs/core/coreapi/interface"
coreiface
"github.com/ipfs/go-ipfs/core/coreapi/interface"
uio
"gx/ipfs/QmWE6Ftsk98cG2MTVgH4wJT8VP2nL9TuBkYTrz9GSqcsh5/go-unixfs/io"
ipfspath
"gx/ipfs/QmdrpbDgeYH3VxkCciQCJY5LkDYdXtig6unDzQmMxFtWEw/go-path"
"gx/ipfs/QmdrpbDgeYH3VxkCciQCJY5LkDYdXtig6unDzQmMxFtWEw/go-path/resolver"
"gx/ipfs/QmPSQnBKM9g7BaUcZCvswUJVscQ1ipjmwxN5PXCjkp9EQ7/go-cid"
"gx/ipfs/QmPSQnBKM9g7BaUcZCvswUJVscQ1ipjmwxN5PXCjkp9EQ7/go-cid"
dag
"gx/ipfs/QmVvNkTCx8V9Zei8xuTYTBdUXmbnDRS4iNuw1SztYyhQwQ/go-merkledag"
uio
"gx/ipfs/QmWE6Ftsk98cG2MTVgH4wJT8VP2nL9TuBkYTrz9GSqcsh5/go-unixfs/io"
ipld
"gx/ipfs/QmdDXJs4axxefSPgK6Y1QhpJWKuDPnGJiqgq4uncb4rFHL/go-ipld-format"
ipld
"gx/ipfs/QmdDXJs4axxefSPgK6Y1QhpJWKuDPnGJiqgq4uncb4rFHL/go-ipld-format"
ipfspath
"gx/ipfs/QmdrpbDgeYH3VxkCciQCJY5LkDYdXtig6unDzQmMxFtWEw/go-path"
"gx/ipfs/QmdrpbDgeYH3VxkCciQCJY5LkDYdXtig6unDzQmMxFtWEw/go-path/resolver"
)
)
// ResolveNode resolves the path `p` using Unixfs resolver, gets and returns the
// ResolveNode resolves the path `p` using Unixfs resolver, gets and returns the
...
@@ -73,3 +74,8 @@ func (api *CoreAPI) ResolvePath(ctx context.Context, p coreiface.Path) (coreifac
...
@@ -73,3 +74,8 @@ func (api *CoreAPI) ResolvePath(ctx context.Context, p coreiface.Path) (coreifac
return
coreiface
.
NewResolvedPath
(
ipath
,
node
,
root
,
gopath
.
Join
(
rest
...
)),
nil
return
coreiface
.
NewResolvedPath
(
ipath
,
node
,
root
,
gopath
.
Join
(
rest
...
)),
nil
}
}
func
(
api
*
CoreAPI
)
getSession
(
ctx
context
.
Context
)
*
CoreAPI
{
ng
:=
dag
.
NewReadOnlyDagService
(
dag
.
NewSession
(
ctx
,
api
.
dag
))
return
&
CoreAPI
{
api
.
node
,
ng
}
}
core/coreapi/unixfs.go
浏览文件 @
a4cb0602
...
@@ -134,13 +134,14 @@ func (api *UnixfsAPI) Add(ctx context.Context, files files.File, opts ...options
...
@@ -134,13 +134,14 @@ func (api *UnixfsAPI) Add(ctx context.Context, files files.File, opts ...options
}
}
func
(
api
*
UnixfsAPI
)
Get
(
ctx
context
.
Context
,
p
coreiface
.
Path
)
(
coreiface
.
UnixfsFile
,
error
)
{
func
(
api
*
UnixfsAPI
)
Get
(
ctx
context
.
Context
,
p
coreiface
.
Path
)
(
coreiface
.
UnixfsFile
,
error
)
{
nd
,
err
:=
api
.
core
()
.
ResolveNode
(
ctx
,
p
)
ses
:=
api
.
core
()
.
getSession
(
ctx
)
nd
,
err
:=
ses
.
ResolveNode
(
ctx
,
p
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
ses
:=
dag
.
NewReadOnlyDagService
(
dag
.
NewSession
(
ctx
,
api
.
node
.
DAG
))
return
newUnixfsFile
(
ctx
,
ses
.
dag
,
nd
,
""
,
nil
)
return
newUnixfsFile
(
ctx
,
ses
,
nd
,
""
,
nil
)
}
}
// Ls returns the contents of an IPFS or IPNS object(s) at path p, with the format:
// Ls returns the contents of an IPFS or IPNS object(s) at path p, with the format:
...
@@ -173,6 +174,6 @@ func (api *UnixfsAPI) Ls(ctx context.Context, p coreiface.Path) ([]*ipld.Link, e
...
@@ -173,6 +174,6 @@ func (api *UnixfsAPI) Ls(ctx context.Context, p coreiface.Path) ([]*ipld.Link, e
return
links
,
nil
return
links
,
nil
}
}
func
(
api
*
UnixfsAPI
)
core
()
coreiface
.
CoreAPI
{
func
(
api
*
UnixfsAPI
)
core
()
*
CoreAPI
{
return
(
*
CoreAPI
)(
api
)
return
(
*
CoreAPI
)(
api
)
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论