Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
9dd12922
提交
9dd12922
authored
2月 03, 2015
作者:
Brian Tiger Chow
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor(routing) expose Bootstrap() error on routing interface
上级
1dfcce9f
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
22 行增加
和
2 行删除
+22
-2
bootstrap.go
core/bootstrap.go
+1
-1
dht_bootstrap.go
routing/dht/dht_bootstrap.go
+7
-1
centralized_client.go
routing/mock/centralized_client.go
+4
-0
offline.go
routing/offline/offline.go
+4
-0
routing.go
routing/routing.go
+6
-0
没有找到文件。
core/bootstrap.go
浏览文件 @
9dd12922
...
@@ -106,7 +106,7 @@ func Bootstrap(n *IpfsNode, cfg BootstrapConfig) (io.Closer, error) {
...
@@ -106,7 +106,7 @@ func Bootstrap(n *IpfsNode, cfg BootstrapConfig) (io.Closer, error) {
proc
.
Go
(
periodic
)
// run one right now.
proc
.
Go
(
periodic
)
// run one right now.
// kick off dht bootstrapping.
// kick off dht bootstrapping.
dbproc
,
err
:=
thedht
.
Bootstrap
(
dht
.
DefaultBootstrapConfig
)
dbproc
,
err
:=
thedht
.
Bootstrap
WithConfig
(
dht
.
DefaultBootstrapConfig
)
if
err
!=
nil
{
if
err
!=
nil
{
proc
.
Close
()
proc
.
Close
()
return
nil
,
err
return
nil
,
err
...
...
routing/dht/dht_bootstrap.go
浏览文件 @
9dd12922
...
@@ -4,6 +4,7 @@ package dht
...
@@ -4,6 +4,7 @@ package dht
import
(
import
(
"crypto/rand"
"crypto/rand"
"errors"
"fmt"
"fmt"
"sync"
"sync"
"time"
"time"
...
@@ -44,13 +45,18 @@ var DefaultBootstrapConfig = BootstrapConfig{
...
@@ -44,13 +45,18 @@ var DefaultBootstrapConfig = BootstrapConfig{
Timeout
:
time
.
Duration
(
20
*
time
.
Second
),
Timeout
:
time
.
Duration
(
20
*
time
.
Second
),
}
}
func
(
dht
*
IpfsDHT
)
Bootstrap
(
context
.
Context
)
error
{
// Bootstrap satisfies the routing interface
return
errors
.
New
(
"TODO: perform DHT bootstrap"
)
}
// Bootstrap ensures the dht routing table remains healthy as peers come and go.
// Bootstrap ensures the dht routing table remains healthy as peers come and go.
// it builds up a list of peers by requesting random peer IDs. The Bootstrap
// it builds up a list of peers by requesting random peer IDs. The Bootstrap
// process will run a number of queries each time, and run every time signal fires.
// process will run a number of queries each time, and run every time signal fires.
// These parameters are configurable.
// These parameters are configurable.
//
//
// Bootstrap returns a process, so the user can stop it.
// Bootstrap returns a process, so the user can stop it.
func
(
dht
*
IpfsDHT
)
Bootstrap
(
config
BootstrapConfig
)
(
goprocess
.
Process
,
error
)
{
func
(
dht
*
IpfsDHT
)
Bootstrap
WithConfig
(
config
BootstrapConfig
)
(
goprocess
.
Process
,
error
)
{
sig
:=
time
.
Tick
(
config
.
Period
)
sig
:=
time
.
Tick
(
config
.
Period
)
return
dht
.
BootstrapOnSignal
(
config
,
sig
)
return
dht
.
BootstrapOnSignal
(
config
,
sig
)
}
}
...
...
routing/mock/centralized_client.go
浏览文件 @
9dd12922
...
@@ -84,4 +84,8 @@ func (c *client) Ping(ctx context.Context, p peer.ID) (time.Duration, error) {
...
@@ -84,4 +84,8 @@ func (c *client) Ping(ctx context.Context, p peer.ID) (time.Duration, error) {
return
0
,
nil
return
0
,
nil
}
}
func
(
c
*
client
)
Bootstrap
(
context
.
Context
)
error
{
return
nil
}
var
_
routing
.
IpfsRouting
=
&
client
{}
var
_
routing
.
IpfsRouting
=
&
client
{}
routing/offline/offline.go
浏览文件 @
9dd12922
...
@@ -89,5 +89,9 @@ func (c *offlineRouting) Ping(ctx context.Context, p peer.ID) (time.Duration, er
...
@@ -89,5 +89,9 @@ func (c *offlineRouting) Ping(ctx context.Context, p peer.ID) (time.Duration, er
return
0
,
ErrOffline
return
0
,
ErrOffline
}
}
func
(
c
*
offlineRouting
)
Bootstrap
(
context
.
Context
)
(
error
)
{
return
nil
}
// ensure offlineRouting matches the IpfsRouting interface
// ensure offlineRouting matches the IpfsRouting interface
var
_
routing
.
IpfsRouting
=
&
offlineRouting
{}
var
_
routing
.
IpfsRouting
=
&
offlineRouting
{}
routing/routing.go
浏览文件 @
9dd12922
...
@@ -40,4 +40,10 @@ type IpfsRouting interface {
...
@@ -40,4 +40,10 @@ type IpfsRouting interface {
// Ping a peer, log the time it took
// Ping a peer, log the time it took
Ping
(
context
.
Context
,
peer
.
ID
)
(
time
.
Duration
,
error
)
Ping
(
context
.
Context
,
peer
.
ID
)
(
time
.
Duration
,
error
)
// Bootstrap allows callers to hint to the routing system to get into a
// Boostrapped state
Bootstrap
(
context
.
Context
)
error
// TODO expose io.Closer or plain-old Close error
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论