Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
58ea9701
Unverified
提交
58ea9701
authored
7月 11, 2019
作者:
Michael Muré
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
pin cmd: better struct naming
上级
dd06956d
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
15 行增加
和
15 行删除
+15
-15
pin.go
core/commands/pin.go
+15
-15
没有找到文件。
core/commands/pin.go
浏览文件 @
58ea9701
...
...
@@ -339,11 +339,11 @@ Example:
// For backward compatibility, we accumulate the pins in the same output type as before.
emit
:=
res
.
Emit
lgcList
:=
map
[
string
]
RefObject
{}
lgcList
:=
map
[
string
]
PinLsType
{}
if
!
stream
{
emit
=
func
(
v
interface
{})
error
{
obj
:=
v
.
(
*
PinLsOutputWrapper
)
lgcList
[
obj
.
RefKeyObject
.
Cid
]
=
RefObject
{
Type
:
obj
.
RefKey
Object
.
Type
}
lgcList
[
obj
.
PinLsObject
.
Cid
]
=
PinLsType
{
Type
:
obj
.
PinLs
Object
.
Type
}
return
nil
}
}
...
...
@@ -359,7 +359,7 @@ Example:
if
!
stream
{
return
cmds
.
EmitOnce
(
res
,
&
PinLsOutputWrapper
{
RefKeyList
:
RefKey
List
{
Keys
:
lgcList
},
PinLsList
:
PinLs
List
{
Keys
:
lgcList
},
})
}
...
...
@@ -373,14 +373,14 @@ Example:
if
stream
{
if
quiet
{
fmt
.
Fprintf
(
w
,
"%s
\n
"
,
out
.
RefKey
Object
.
Cid
)
fmt
.
Fprintf
(
w
,
"%s
\n
"
,
out
.
PinLs
Object
.
Cid
)
}
else
{
fmt
.
Fprintf
(
w
,
"%s %s
\n
"
,
out
.
RefKeyObject
.
Cid
,
out
.
RefKey
Object
.
Type
)
fmt
.
Fprintf
(
w
,
"%s %s
\n
"
,
out
.
PinLsObject
.
Cid
,
out
.
PinLs
Object
.
Type
)
}
return
nil
}
for
k
,
v
:=
range
out
.
RefKey
List
.
Keys
{
for
k
,
v
:=
range
out
.
PinLs
List
.
Keys
{
if
quiet
{
fmt
.
Fprintf
(
w
,
"%s
\n
"
,
k
)
}
else
{
...
...
@@ -393,24 +393,24 @@ Example:
},
}
type
RefKey
Object
struct
{
type
PinLs
Object
struct
{
Cid
string
`json:",omitempty"`
Type
string
`json:",omitempty"`
}
type
RefObject
struct
{
type
PinLsType
struct
{
Type
string
}
type
RefKey
List
struct
{
Keys
map
[
string
]
RefObject
`json:",omitempty"`
type
PinLs
List
struct
{
Keys
map
[
string
]
PinLsType
`json:",omitempty"`
}
// Pin ls needs to output two different type depending on if it's streamed or not.
// We use this to bypass the cmds lib refusing to have interface{}
type
PinLsOutputWrapper
struct
{
RefKey
List
RefKey
Object
PinLs
List
PinLs
Object
}
func
pinLsKeys
(
req
*
cmds
.
Request
,
typeStr
string
,
n
*
core
.
IpfsNode
,
api
coreiface
.
CoreAPI
,
emit
func
(
value
interface
{})
error
)
error
{
...
...
@@ -446,7 +446,7 @@ func pinLsKeys(req *cmds.Request, typeStr string, n *core.IpfsNode, api coreifac
}
err
=
emit
(
&
PinLsOutputWrapper
{
RefKeyObject
:
RefKey
Object
{
PinLsObject
:
PinLs
Object
{
Type
:
pinType
,
Cid
:
enc
.
Encode
(
c
.
Cid
()),
},
...
...
@@ -471,7 +471,7 @@ func pinLsAll(req *cmds.Request, typeStr string, n *core.IpfsNode, emit func(val
for
_
,
c
:=
range
keyList
{
if
keys
.
Visit
(
c
)
{
err
:=
emit
(
&
PinLsOutputWrapper
{
RefKeyObject
:
RefKey
Object
{
PinLsObject
:
PinLs
Object
{
Type
:
typeStr
,
Cid
:
enc
.
Encode
(
c
),
},
...
...
@@ -497,7 +497,7 @@ func pinLsAll(req *cmds.Request, typeStr string, n *core.IpfsNode, emit func(val
r
:=
keys
.
Visit
(
c
)
if
r
{
err
:=
emit
(
&
PinLsOutputWrapper
{
RefKeyObject
:
RefKey
Object
{
PinLsObject
:
PinLs
Object
{
Type
:
typeStr
,
Cid
:
enc
.
Encode
(
c
),
},
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论