Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
72176379
提交
72176379
authored
2月 11, 2016
作者:
Jeromy Johnson
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2328 from ipfs/feat/parallel-pub
put pubkey and ipns entry to dht in parallel
上级
9fbe3d13
abadc94e
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
30 行增加
和
7 行删除
+30
-7
publisher.go
namesys/publisher.go
+21
-2
resolve_test.go
namesys/resolve_test.go
+7
-4
centralized_server.go
routing/mock/centralized_server.go
+2
-1
没有找到文件。
namesys/publisher.go
浏览文件 @
72176379
...
...
@@ -146,12 +146,22 @@ func PutRecordToRouting(ctx context.Context, k ci.PrivKey, value path.Path, seqn
entry
.
Ttl
=
proto
.
Uint64
(
uint64
(
ttl
.
Nanoseconds
()))
}
err
=
PublishEntry
(
ctx
,
r
,
ipnskey
,
entry
)
errs
:=
make
(
chan
error
)
go
func
()
{
errs
<-
PublishEntry
(
ctx
,
r
,
ipnskey
,
entry
)
}()
go
func
()
{
errs
<-
PublishPublicKey
(
ctx
,
r
,
namekey
,
k
.
GetPublic
())
}()
err
=
waitOnErrChan
(
ctx
,
errs
)
if
err
!=
nil
{
return
err
}
err
=
PublishPublicKey
(
ctx
,
r
,
namekey
,
k
.
GetPublic
()
)
err
=
waitOnErrChan
(
ctx
,
errs
)
if
err
!=
nil
{
return
err
}
...
...
@@ -159,6 +169,15 @@ func PutRecordToRouting(ctx context.Context, k ci.PrivKey, value path.Path, seqn
return
nil
}
func
waitOnErrChan
(
ctx
context
.
Context
,
errs
chan
error
)
error
{
select
{
case
err
:=
<-
errs
:
return
err
case
<-
ctx
.
Done
()
:
return
ctx
.
Err
()
}
}
func
PublishPublicKey
(
ctx
context
.
Context
,
r
routing
.
IpfsRouting
,
k
key
.
Key
,
pubk
ci
.
PubKey
)
error
{
log
.
Debugf
(
"Storing pubkey at: %s"
,
k
)
pkbytes
,
err
:=
pubk
.
Bytes
()
...
...
namesys/resolve_test.go
浏览文件 @
72176379
...
...
@@ -6,6 +6,7 @@ import (
"time"
ds
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
dssync
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore/sync"
key
"github.com/ipfs/go-ipfs/blocks/key"
path
"github.com/ipfs/go-ipfs/path"
mockrouting
"github.com/ipfs/go-ipfs/routing/mock"
...
...
@@ -16,8 +17,10 @@ import (
)
func
TestRoutingResolve
(
t
*
testing
.
T
)
{
d
:=
mockrouting
.
NewServer
()
.
Client
(
testutil
.
RandIdentityOrFatal
(
t
))
dstore
:=
ds
.
NewMapDatastore
()
dstore
:=
dssync
.
MutexWrap
(
ds
.
NewMapDatastore
())
serv
:=
mockrouting
.
NewServer
()
id
:=
testutil
.
RandIdentityOrFatal
(
t
)
d
:=
serv
.
ClientWithDatastore
(
context
.
Background
(),
id
,
dstore
)
resolver
:=
NewRoutingResolver
(
d
,
0
)
publisher
:=
NewRoutingPublisher
(
d
,
dstore
)
...
...
@@ -50,7 +53,7 @@ func TestRoutingResolve(t *testing.T) {
}
func
TestPrexistingExpiredRecord
(
t
*
testing
.
T
)
{
dstore
:=
ds
.
NewMapDatastore
(
)
dstore
:=
ds
sync
.
MutexWrap
(
ds
.
NewMapDatastore
()
)
d
:=
mockrouting
.
NewServer
()
.
ClientWithDatastore
(
context
.
Background
(),
testutil
.
RandIdentityOrFatal
(
t
),
dstore
)
resolver
:=
NewRoutingResolver
(
d
,
0
)
...
...
@@ -87,7 +90,7 @@ func TestPrexistingExpiredRecord(t *testing.T) {
}
func
TestPrexistingRecord
(
t
*
testing
.
T
)
{
dstore
:=
ds
.
NewMapDatastore
(
)
dstore
:=
ds
sync
.
MutexWrap
(
ds
.
NewMapDatastore
()
)
d
:=
mockrouting
.
NewServer
()
.
ClientWithDatastore
(
context
.
Background
(),
testutil
.
RandIdentityOrFatal
(
t
),
dstore
)
resolver
:=
NewRoutingResolver
(
d
,
0
)
...
...
routing/mock/centralized_server.go
浏览文件 @
72176379
...
...
@@ -6,6 +6,7 @@ import (
"time"
ds
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
dssync
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore/sync"
key
"github.com/ipfs/go-ipfs/blocks/key"
"github.com/ipfs/go-ipfs/util/testutil"
peer
"gx/ipfs/QmUBogf4nUefBjmYjn6jfsfPJRkmDGSeMhNj4usRKq69f4/go-libp2p/p2p/peer"
...
...
@@ -74,7 +75,7 @@ func (rs *s) Providers(k key.Key) []peer.PeerInfo {
}
func
(
rs
*
s
)
Client
(
p
testutil
.
Identity
)
Client
{
return
rs
.
ClientWithDatastore
(
context
.
Background
(),
p
,
ds
.
NewMapDatastore
(
))
return
rs
.
ClientWithDatastore
(
context
.
Background
(),
p
,
ds
sync
.
MutexWrap
(
ds
.
NewMapDatastore
()
))
}
func
(
rs
*
s
)
ClientWithDatastore
(
_
context
.
Context
,
p
testutil
.
Identity
,
datastore
ds
.
Datastore
)
Client
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论