Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
4d4d7b8e
提交
4d4d7b8e
authored
5月 01, 2017
作者:
Michael Muré
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Implement ipfs key rm
License: MIT Signed-off-by:
Michael Muré
<
batolettre@gmail.com
>
上级
f44ff30e
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
64 行增加
和
0 行删除
+64
-0
keystore.go
core/commands/keystore.go
+56
-0
t0165-keystore.sh
test/sharness/t0165-keystore.sh
+8
-0
没有找到文件。
core/commands/keystore.go
浏览文件 @
4d4d7b8e
...
...
@@ -35,6 +35,7 @@ var KeyCmd = &cmds.Command{
Subcommands
:
map
[
string
]
*
cmds
.
Command
{
"gen"
:
KeyGenCmd
,
"list"
:
KeyListCmd
,
"rm"
:
KeyRmCmd
,
},
}
...
...
@@ -202,6 +203,61 @@ var KeyListCmd = &cmds.Command{
Type
:
KeyOutputList
{},
}
var
KeyRmCmd
=
&
cmds
.
Command
{
Helptext
:
cmds
.
HelpText
{
Tagline
:
"Remove a keypair"
,
},
Arguments
:
[]
cmds
.
Argument
{
cmds
.
StringArg
(
"name"
,
true
,
false
,
"name of key to remove"
),
},
Run
:
func
(
req
cmds
.
Request
,
res
cmds
.
Response
)
{
n
,
err
:=
req
.
InvocContext
()
.
GetNode
()
if
err
!=
nil
{
res
.
SetError
(
err
,
cmds
.
ErrNormal
)
return
}
name
:=
req
.
Arguments
()[
0
]
if
name
==
"self"
{
res
.
SetError
(
fmt
.
Errorf
(
"cannot remove key with name 'self'"
),
cmds
.
ErrNormal
)
return
}
removed
,
err
:=
n
.
Repo
.
Keystore
()
.
Get
(
name
)
if
err
!=
nil
{
res
.
SetError
(
err
,
cmds
.
ErrNormal
)
return
}
err
=
n
.
Repo
.
Keystore
()
.
Delete
(
name
)
if
err
!=
nil
{
res
.
SetError
(
err
,
cmds
.
ErrNormal
)
return
}
pubKey
:=
removed
.
GetPublic
()
pid
,
err
:=
peer
.
IDFromPublicKey
(
pubKey
)
if
err
!=
nil
{
res
.
SetError
(
err
,
cmds
.
ErrNormal
)
return
}
res
.
SetOutput
(
&
KeyOutput
{
Name
:
name
,
Id
:
pid
.
Pretty
(),
})
},
Marshalers
:
cmds
.
MarshalerMap
{
cmds
.
Text
:
func
(
res
cmds
.
Response
)
(
io
.
Reader
,
error
)
{
v
:=
res
.
Output
()
.
(
*
KeyOutput
)
s
:=
fmt
.
Sprintf
(
"Removed key %s with Id: %s
\n
"
,
v
.
Name
,
v
.
Id
)
return
strings
.
NewReader
(
s
),
nil
},
},
Type
:
KeyOutput
{},
}
func
keyOutputListMarshaler
(
res
cmds
.
Response
)
(
io
.
Reader
,
error
)
{
withId
,
_
,
_
:=
res
.
Request
()
.
Option
(
"l"
)
.
Bool
()
...
...
test/sharness/t0165-keystore.sh
浏览文件 @
4d4d7b8e
...
...
@@ -36,6 +36,14 @@ test_key_cmd() {
PeerID="$(ipfs config Identity.PeerID)"
ipfs key list -l | grep "$PeerID self"
'
test_expect_success
"key rm remove a key"
'
ipfs key rm foobarsa
echo bazed > list_exp &&
echo self >> list_exp
ipfs key list | sort > list_out &&
test_cmp list_exp list_out
'
}
test_key_cmd
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论