Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
2d675312
提交
2d675312
authored
3月 17, 2015
作者:
Juan Batiz-Benet
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #938 from jbenet/refactor/keyspace
Refactor/keyspace
上级
b0364396
c100b1be
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
34 行增加
和
5 行删除
+34
-5
init.go
cmd/ipfs/init.go
+2
-2
publisher.go
namesys/publisher.go
+32
-3
没有找到文件。
cmd/ipfs/init.go
浏览文件 @
2d675312
...
...
@@ -10,7 +10,7 @@ import (
cmds
"github.com/jbenet/go-ipfs/commands"
core
"github.com/jbenet/go-ipfs/core"
coreunix
"github.com/jbenet/go-ipfs/core/coreunix"
ipns
"github.com/jbenet/go-ipfs/fuse/ipn
s"
namesys
"github.com/jbenet/go-ipfs/namesy
s"
config
"github.com/jbenet/go-ipfs/repo/config"
fsrepo
"github.com/jbenet/go-ipfs/repo/fsrepo"
uio
"github.com/jbenet/go-ipfs/unixfs/io"
...
...
@@ -179,5 +179,5 @@ func initializeIpnsKeyspace(repoRoot string) error {
return
err
}
return
ipns
.
InitializeKeyspace
(
nd
,
nd
.
PrivateKey
)
return
namesys
.
InitializeKeyspace
(
ctx
,
nd
.
DAG
,
nd
.
Namesys
,
nd
.
Pinning
,
nd
.
PrivateKey
)
}
namesys/publisher.go
浏览文件 @
2d675312
...
...
@@ -10,10 +10,13 @@ import (
mh
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multihash"
context
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
dag
"github.com/jbenet/go-ipfs/merkledag"
pb
"github.com/jbenet/go-ipfs/namesys/internal/pb"
ci
"github.com/jbenet/go-ipfs/p2p/crypto"
pin
"github.com/jbenet/go-ipfs/pin"
routing
"github.com/jbenet/go-ipfs/routing"
record
"github.com/jbenet/go-ipfs/routing/record"
ft
"github.com/jbenet/go-ipfs/unixfs"
u
"github.com/jbenet/go-ipfs/util"
)
...
...
@@ -60,11 +63,9 @@ func (p *ipnsPublisher) Publish(ctx context.Context, k ci.PrivKey, value u.Key)
nameb
:=
u
.
Hash
(
pkbytes
)
namekey
:=
u
.
Key
(
"/pk/"
+
string
(
nameb
))
timectx
,
cancel
:=
context
.
WithDeadline
(
ctx
,
time
.
Now
()
.
Add
(
time
.
Second
*
10
))
defer
cancel
()
log
.
Debugf
(
"Storing pubkey at: %s"
,
namekey
)
// Store associated public key
timectx
,
_
:=
context
.
WithDeadline
(
ctx
,
time
.
Now
()
.
Add
(
time
.
Second
*
10
))
err
=
p
.
routing
.
PutValue
(
timectx
,
namekey
,
pkbytes
)
if
err
!=
nil
{
return
err
...
...
@@ -136,3 +137,31 @@ func ValidateIpnsRecord(k u.Key, val []byte) error {
}
return
nil
}
// InitializeKeyspace sets the ipns record for the given key to
// point to an empty directory.
// TODO: this doesnt feel like it belongs here
func
InitializeKeyspace
(
ctx
context
.
Context
,
ds
dag
.
DAGService
,
pub
Publisher
,
pins
pin
.
Pinner
,
key
ci
.
PrivKey
)
error
{
emptyDir
:=
&
dag
.
Node
{
Data
:
ft
.
FolderPBData
()}
nodek
,
err
:=
ds
.
Add
(
emptyDir
)
if
err
!=
nil
{
return
err
}
err
=
pins
.
Pin
(
emptyDir
,
false
)
if
err
!=
nil
{
return
err
}
err
=
pins
.
Flush
()
if
err
!=
nil
{
return
err
}
err
=
pub
.
Publish
(
ctx
,
key
,
nodek
)
if
err
!=
nil
{
return
err
}
return
nil
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论