Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
838aeb9b
提交
838aeb9b
authored
10月 23, 2018
作者:
Łukasz Magiera
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
coreapi unixfs: docs for getSession, use api.dag
License: MIT Signed-off-by:
Łukasz Magiera
<
magik6k@gmail.com
>
上级
a4cb0602
显示空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
24 行增加
和
20 行删除
+24
-20
coreapi.go
core/coreapi/coreapi.go
+10
-0
dag.go
core/coreapi/dag.go
+2
-2
object.go
core/coreapi/object.go
+8
-8
path.go
core/coreapi/path.go
+2
-8
pin.go
core/coreapi/pin.go
+1
-1
unixfs.go
core/coreapi/unixfs.go
+1
-1
没有找到文件。
core/coreapi/coreapi.go
浏览文件 @
838aeb9b
...
...
@@ -14,9 +14,12 @@ Interfaces here aren't yet completely stable.
package
coreapi
import
(
"context"
core
"github.com/ipfs/go-ipfs/core"
coreiface
"github.com/ipfs/go-ipfs/core/coreapi/interface"
dag
"gx/ipfs/QmVvNkTCx8V9Zei8xuTYTBdUXmbnDRS4iNuw1SztYyhQwQ/go-merkledag"
logging
"gx/ipfs/QmZChCsSt8DctjceaL56Eibc29CVQq4dGKRXC5JRZ6Ppae/go-log"
ipld
"gx/ipfs/QmdDXJs4axxefSPgK6Y1QhpJWKuDPnGJiqgq4uncb4rFHL/go-ipld-format"
)
...
...
@@ -83,3 +86,9 @@ func (api *CoreAPI) Swarm() coreiface.SwarmAPI {
func
(
api
*
CoreAPI
)
PubSub
()
coreiface
.
PubSubAPI
{
return
(
*
PubSubAPI
)(
api
)
}
// getSession returns new api backed by the same node with a read-only session DAG
func
(
api
*
CoreAPI
)
getSession
(
ctx
context
.
Context
)
*
CoreAPI
{
ng
:=
dag
.
NewReadOnlyDagService
(
dag
.
NewSession
(
ctx
,
api
.
dag
))
return
&
CoreAPI
{
api
.
node
,
ng
}
}
\ No newline at end of file
core/coreapi/dag.go
浏览文件 @
838aeb9b
...
...
@@ -31,7 +31,7 @@ type dagBatch struct {
func
(
api
*
DagAPI
)
Put
(
ctx
context
.
Context
,
src
io
.
Reader
,
opts
...
caopts
.
DagPutOption
)
(
coreiface
.
ResolvedPath
,
error
)
{
nd
,
err
:=
getNode
(
src
,
opts
...
)
err
=
api
.
node
.
DAG
.
Add
(
ctx
,
nd
)
err
=
api
.
dag
.
Add
(
ctx
,
nd
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -96,7 +96,7 @@ func (b *dagBatch) Commit(ctx context.Context) error {
b
.
toPut
=
nil
}()
return
b
.
api
.
node
.
DAG
.
AddMany
(
ctx
,
b
.
toPut
)
return
b
.
api
.
dag
.
AddMany
(
ctx
,
b
.
toPut
)
}
func
getNode
(
src
io
.
Reader
,
opts
...
caopts
.
DagPutOption
)
(
ipld
.
Node
,
error
)
{
...
...
core/coreapi/object.go
浏览文件 @
838aeb9b
...
...
@@ -50,7 +50,7 @@ func (api *ObjectAPI) New(ctx context.Context, opts ...caopts.ObjectNewOption) (
n
=
ft
.
EmptyDirNode
()
}
err
=
api
.
node
.
DAG
.
Add
(
ctx
,
n
)
err
=
api
.
dag
.
Add
(
ctx
,
n
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -121,7 +121,7 @@ func (api *ObjectAPI) Put(ctx context.Context, src io.Reader, opts ...caopts.Obj
defer
api
.
node
.
Blockstore
.
PinLock
()
.
Unlock
()
}
err
=
api
.
node
.
DAG
.
Add
(
ctx
,
dagnode
)
err
=
api
.
dag
.
Add
(
ctx
,
dagnode
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -219,14 +219,14 @@ func (api *ObjectAPI) AddLink(ctx context.Context, base coreiface.Path, name str
createfunc
=
ft
.
EmptyDirNode
}
e
:=
dagutils
.
NewDagEditor
(
basePb
,
api
.
node
.
DAG
)
e
:=
dagutils
.
NewDagEditor
(
basePb
,
api
.
dag
)
err
=
e
.
InsertNodeAtPath
(
ctx
,
name
,
childNd
,
createfunc
)
if
err
!=
nil
{
return
nil
,
err
}
nnode
,
err
:=
e
.
Finalize
(
ctx
,
api
.
node
.
DAG
)
nnode
,
err
:=
e
.
Finalize
(
ctx
,
api
.
dag
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -245,14 +245,14 @@ func (api *ObjectAPI) RmLink(ctx context.Context, base coreiface.Path, link stri
return
nil
,
dag
.
ErrNotProtobuf
}
e
:=
dagutils
.
NewDagEditor
(
basePb
,
api
.
node
.
DAG
)
e
:=
dagutils
.
NewDagEditor
(
basePb
,
api
.
dag
)
err
=
e
.
RmLink
(
ctx
,
link
)
if
err
!=
nil
{
return
nil
,
err
}
nnode
,
err
:=
e
.
Finalize
(
ctx
,
api
.
node
.
DAG
)
nnode
,
err
:=
e
.
Finalize
(
ctx
,
api
.
dag
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -289,7 +289,7 @@ func (api *ObjectAPI) patchData(ctx context.Context, path coreiface.Path, r io.R
}
pbnd
.
SetData
(
data
)
err
=
api
.
node
.
DAG
.
Add
(
ctx
,
pbnd
)
err
=
api
.
dag
.
Add
(
ctx
,
pbnd
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -308,7 +308,7 @@ func (api *ObjectAPI) Diff(ctx context.Context, before coreiface.Path, after cor
return
nil
,
err
}
changes
,
err
:=
dagutils
.
Diff
(
ctx
,
api
.
node
.
DAG
,
beforeNd
,
afterNd
)
changes
,
err
:=
dagutils
.
Diff
(
ctx
,
api
.
dag
,
beforeNd
,
afterNd
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
core/coreapi/path.go
浏览文件 @
838aeb9b
...
...
@@ -9,7 +9,6 @@ import (
coreiface
"github.com/ipfs/go-ipfs/core/coreapi/interface"
"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"
ipfspath
"gx/ipfs/QmdrpbDgeYH3VxkCciQCJY5LkDYdXtig6unDzQmMxFtWEw/go-path"
...
...
@@ -24,7 +23,7 @@ func (api *CoreAPI) ResolveNode(ctx context.Context, p coreiface.Path) (ipld.Nod
return
nil
,
err
}
node
,
err
:=
api
.
node
.
DAG
.
Get
(
ctx
,
rp
.
Cid
())
node
,
err
:=
api
.
dag
.
Get
(
ctx
,
rp
.
Cid
())
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -58,7 +57,7 @@ func (api *CoreAPI) ResolvePath(ctx context.Context, p coreiface.Path) (coreifac
}
r
:=
&
resolver
.
Resolver
{
DAG
:
api
.
node
.
DAG
,
DAG
:
api
.
dag
,
ResolveOnce
:
resolveOnce
,
}
...
...
@@ -74,8 +73,3 @@ func (api *CoreAPI) ResolvePath(ctx context.Context, p coreiface.Path) (coreifac
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/pin.go
浏览文件 @
838aeb9b
...
...
@@ -193,7 +193,7 @@ func (api *PinAPI) pinLsAll(typeStr string, ctx context.Context) ([]coreiface.Pi
if
typeStr
==
"indirect"
||
typeStr
==
"all"
{
set
:=
cid
.
NewSet
()
for
_
,
k
:=
range
api
.
node
.
Pinning
.
RecursiveKeys
()
{
err
:=
merkledag
.
EnumerateChildren
(
ctx
,
merkledag
.
GetLinksWithDAG
(
api
.
node
.
DAG
),
k
,
set
.
Visit
)
err
:=
merkledag
.
EnumerateChildren
(
ctx
,
merkledag
.
GetLinksWithDAG
(
api
.
dag
),
k
,
set
.
Visit
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
core/coreapi/unixfs.go
浏览文件 @
838aeb9b
...
...
@@ -153,7 +153,7 @@ func (api *UnixfsAPI) Ls(ctx context.Context, p coreiface.Path) ([]*ipld.Link, e
}
var
ndlinks
[]
*
ipld
.
Link
dir
,
err
:=
uio
.
NewDirectoryFromNode
(
api
.
node
.
DAG
,
dagnode
)
dir
,
err
:=
uio
.
NewDirectoryFromNode
(
api
.
dag
,
dagnode
)
switch
err
{
case
nil
:
l
,
err
:=
dir
.
Links
(
ctx
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论