Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
252ddc82
提交
252ddc82
authored
1月 22, 2018
作者:
ForrestWeston
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
docs for coreapi key method impls
License: MIT Signed-off-by:
ForrestWeston
<
forrest@protocol.ai
>
上级
132c939d
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
8 行增加
和
0 行删除
+8
-0
key.go
core/coreapi/key.go
+8
-0
没有找到文件。
core/coreapi/key.go
浏览文件 @
252ddc82
...
...
@@ -24,14 +24,18 @@ type key struct {
peerId
string
}
// Name returns the key name
func
(
k
*
key
)
Name
()
string
{
return
k
.
name
}
// Path returns the path of the key.
func
(
k
*
key
)
Path
()
coreiface
.
Path
{
return
&
path
{
path
:
ipfspath
.
FromString
(
ipfspath
.
Join
([]
string
{
"/ipns"
,
k
.
peerId
}))}
}
// Generate generates new key, stores it in the keystore under the specified
// name and returns a base58 encoded multihash of its public key.
func
(
api
*
KeyAPI
)
Generate
(
ctx
context
.
Context
,
name
string
,
opts
...
caopts
.
KeyGenerateOption
)
(
coreiface
.
Key
,
error
)
{
options
,
err
:=
caopts
.
KeyGenerateOptions
(
opts
...
)
if
err
!=
nil
{
...
...
@@ -88,6 +92,7 @@ func (api *KeyAPI) Generate(ctx context.Context, name string, opts ...caopts.Key
return
&
key
{
name
,
pid
.
Pretty
()},
nil
}
// List returns a list keys stored in keystore.
func
(
api
*
KeyAPI
)
List
(
ctx
context
.
Context
)
([]
coreiface
.
Key
,
error
)
{
keys
,
err
:=
api
.
node
.
Repo
.
Keystore
()
.
List
()
if
err
!=
nil
{
...
...
@@ -117,6 +122,8 @@ func (api *KeyAPI) List(ctx context.Context) ([]coreiface.Key, error) {
return
out
,
nil
}
// Rename renames `oldName` to `newName`. Returns the key and whether another
// key was overwritten, or an error.
func
(
api
*
KeyAPI
)
Rename
(
ctx
context
.
Context
,
oldName
string
,
newName
string
,
opts
...
caopts
.
KeyRenameOption
)
(
coreiface
.
Key
,
bool
,
error
)
{
options
,
err
:=
caopts
.
KeyRenameOptions
(
opts
...
)
if
err
!=
nil
{
...
...
@@ -169,6 +176,7 @@ func (api *KeyAPI) Rename(ctx context.Context, oldName string, newName string, o
return
&
key
{
newName
,
pid
.
Pretty
()},
overwrite
,
ks
.
Delete
(
oldName
)
}
// Remove removes keys from keystore. Returns ipns path of the removed key.
func
(
api
*
KeyAPI
)
Remove
(
ctx
context
.
Context
,
name
string
)
(
coreiface
.
Path
,
error
)
{
ks
:=
api
.
node
.
Repo
.
Keystore
()
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论