Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
587dc187
提交
587dc187
authored
12月 15, 2017
作者:
Łukasz Magiera
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
coreapi: Documentation for Name/Key
License: MIT Signed-off-by:
Łukasz Magiera
<
magik6k@gmail.com
>
上级
1c73d48e
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
50 行增加
和
9 行删除
+50
-9
coreapi.go
core/coreapi/coreapi.go
+2
-8
interface.go
core/coreapi/interface/interface.go
+47
-0
key.go
core/coreapi/key.go
+1
-1
没有找到文件。
core/coreapi/coreapi.go
浏览文件 @
587dc187
...
...
@@ -30,17 +30,11 @@ func (api *CoreAPI) Dag() coreiface.DagAPI {
}
func
(
api
*
CoreAPI
)
Name
()
coreiface
.
NameAPI
{
return
&
NameAPI
{
api
,
nil
,
}
return
&
NameAPI
{
api
,
nil
}
}
func
(
api
*
CoreAPI
)
Key
()
coreiface
.
KeyAPI
{
return
&
KeyAPI
{
api
,
nil
,
}
return
&
KeyAPI
{
api
,
nil
}
}
func
(
api
*
CoreAPI
)
ResolveNode
(
ctx
context
.
Context
,
p
coreiface
.
Path
)
(
coreiface
.
Node
,
error
)
{
...
...
core/coreapi/interface/interface.go
浏览文件 @
587dc187
...
...
@@ -98,26 +98,73 @@ type DagAPI interface {
WithDepth
(
depth
int
)
options
.
DagTreeOption
}
// NameAPI specifies the interface to IPNS.
//
// IPNS is a PKI namespace, where names are the hashes of public keys, and the
// private key enables publishing new (signed) values. In both publish and
// resolve, the default name used is the node's own PeerID, which is the hash of
// its public key.
//
// You can use .Key API to list and generate more names and their respective keys.
type
NameAPI
interface
{
// Publish announces new IPNS name
Publish
(
ctx
context
.
Context
,
path
Path
,
opts
...
options
.
NamePublishOption
)
(
*
IpnsEntry
,
error
)
// WithValidTime is an option for Publish which specifies for how long the
// entry will remain valid. Default value is 24h
WithValidTime
(
validTime
time
.
Duration
)
options
.
NamePublishOption
// WithKey is an option for Publish which specifies the key to use for
// publishing. Default value is "self" which is the node's own PeerID.
//
// You can use .Key API to list and generate more names and their respective keys.
WithKey
(
key
string
)
options
.
NamePublishOption
// Resolve attempts to resolve the newest version of the specified name
Resolve
(
ctx
context
.
Context
,
name
string
,
opts
...
options
.
NameResolveOption
)
(
Path
,
error
)
// WithRecursive is an option for Resolve which specifies whether to perform a
// recursive lookup. Default value is false
WithRecursive
(
recursive
bool
)
options
.
NameResolveOption
// WithLocal is an option for Resolve which specifies if the lookup should be
// offline. Default value is false
WithLocal
(
local
bool
)
options
.
NameResolveOption
// WithNoCache is an option for Resolve which specifies when set to true
// disables the use of local name cache. Default value is false
WithNoCache
(
nocache
bool
)
options
.
NameResolveOption
}
// KeyAPI specifies the interface to Keystore
type
KeyAPI
interface
{
// Generate generates new key, stores it in the keystore under the specified
// name and returns a base58 encoded multihash of it's public key
Generate
(
ctx
context
.
Context
,
name
string
,
opts
...
options
.
KeyGenerateOption
)
(
string
,
error
)
// WithAlgorithm is an option for Generate which specifies which algorithm
// should be used for the key. Default is "rsa"
//
// Supported algorithms:
// * rsa
// * ed25519
WithAlgorithm
(
algorithm
string
)
options
.
KeyGenerateOption
// WithSize is an option for Generate which specifies the size of the key to
// generated. Default is 0
WithSize
(
size
int
)
options
.
KeyGenerateOption
// Rename renames oldName key to newName.
Rename
(
ctx
context
.
Context
,
oldName
string
,
newName
string
,
opts
...
options
.
KeyRenameOption
)
(
string
,
bool
,
error
)
// WithForce is an option for Rename which specifies whether to allow to
// replace existing keys.
WithForce
(
force
bool
)
options
.
KeyRenameOption
// List lists keys stored in keystore
List
(
ctx
context
.
Context
)
(
map
[
string
]
string
,
error
)
//TODO: better key type?
// Remove removes keys from keystore
Remove
(
ctx
context
.
Context
,
name
string
)
(
string
,
error
)
}
...
...
core/coreapi/key.go
浏览文件 @
587dc187
...
...
@@ -30,7 +30,7 @@ func (api *KeyAPI) Generate(ctx context.Context, name string, opts ...caopts.Key
switch
options
.
Algorithm
{
case
"rsa"
:
if
options
.
Size
==
0
{
return
""
,
fmt
.
Errorf
(
"please specify a key size with
--size
"
)
return
""
,
fmt
.
Errorf
(
"please specify a key size with
WithSize option
"
)
}
priv
,
pub
,
err
:=
crypto
.
GenerateKeyPairWithReader
(
crypto
.
RSA
,
options
.
Size
,
rand
.
Reader
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论