Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
190524b0
Unverified
提交
190524b0
authored
2月 12, 2018
作者:
Whyrusleeping
提交者:
GitHub
2月 12, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #4676 from ipfs/doc/golint-routing
Doc: golint-ify routing module
上级
d3c005a7
953d7d46
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
18 行增加
和
7 行删除
+18
-7
interface.go
routing/mock/interface.go
+7
-5
none_client.go
routing/none/none_client.go
+4
-2
offline.go
routing/offline/offline.go
+7
-0
没有找到文件。
routing/mock/interface.go
浏览文件 @
190524b0
// Package mock
provides a virtual routing server. To use it, create a virtual
//
routing server and use the Client() method to get a routing client
//
(IpfsRouting). The server quacks like a DHT but is really a local in-memory
// hash table.
// Package mock
routing provides a virtual routing server. To use it,
//
create a virtual routing server and use the Client() method to get a
//
routing client (IpfsRouting). The server quacks like a DHT but is
//
really a local in-memory
hash table.
package
mockrouting
import
(
"context"
delay
"github.com/ipfs/go-ipfs/thirdparty/delay"
"gx/ipfs/QmVvkK7s5imCiq3JVbL3pGfnhcCnf3LrFJPF4GE2sAoGZf/go-testutil"
ds
"gx/ipfs/QmPpegoMqhAEqjncrzArm7KVWAkCm78rqL2DPuNjhPrshg/go-datastore"
routing
"gx/ipfs/QmTiWLZ6Fo5j4KcTVutZJ5KWRRJrbxzmxA4td8NfEdrPh7/go-libp2p-routing"
"gx/ipfs/QmVvkK7s5imCiq3JVbL3pGfnhcCnf3LrFJPF4GE2sAoGZf/go-testutil"
peer
"gx/ipfs/QmZoWKhxUmZ2seW4BzX6fJkNR8hh9PsGModr7q171yq2SS/go-libp2p-peer"
)
...
...
@@ -42,6 +42,8 @@ func NewServerWithDelay(conf DelayConfig) Server {
}
}
// DelayConfig can be used to configured the fake delays of a mock server.
// Use with NewServerWithDelay().
type
DelayConfig
struct
{
// ValueVisibility is the time it takes for a value to be visible in the network
// FIXME there _must_ be a better term for this
...
...
routing/none/none_client.go
浏览文件 @
190524b0
// Package nilrouting implements a routing client that does nothing.
package
nilrouting
import
(
...
...
@@ -21,11 +22,11 @@ func (c *nilclient) PutValue(_ context.Context, _ string, _ []byte) error {
}
func
(
c
*
nilclient
)
GetValue
(
_
context
.
Context
,
_
string
)
([]
byte
,
error
)
{
return
nil
,
errors
.
New
(
"
Tried GetValue from nil routing.
"
)
return
nil
,
errors
.
New
(
"
tried GetValue from nil routing
"
)
}
func
(
c
*
nilclient
)
GetValues
(
_
context
.
Context
,
_
string
,
_
int
)
([]
routing
.
RecvdVal
,
error
)
{
return
nil
,
errors
.
New
(
"
Tried GetValues from nil routing.
"
)
return
nil
,
errors
.
New
(
"
tried GetValues from nil routing
"
)
}
func
(
c
*
nilclient
)
FindPeer
(
_
context
.
Context
,
_
peer
.
ID
)
(
pstore
.
PeerInfo
,
error
)
{
...
...
@@ -46,6 +47,7 @@ func (c *nilclient) Bootstrap(_ context.Context) error {
return
nil
}
// ConstructNilRouting creates an IpfsRouting client which does nothing.
func
ConstructNilRouting
(
_
context
.
Context
,
_
p2phost
.
Host
,
_
repo
.
Datastore
)
(
routing
.
IpfsRouting
,
error
)
{
return
&
nilclient
{},
nil
}
...
...
routing/offline/offline.go
浏览文件 @
190524b0
// Package offline implements IpfsRouting with a client which
// is only able to perform offline operations.
package
offline
import
(
...
...
@@ -18,8 +20,13 @@ import (
cid
"gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
)
// ErrOffline is returned when trying to perform operations that
// require connectivity.
var
ErrOffline
=
errors
.
New
(
"routing system in offline mode"
)
// NewOfflineRouter returns an IpfsRouting implementation which only performs
// offline operations. It allows to Put and Get signed dht
// records to and from the local datastore.
func
NewOfflineRouter
(
dstore
ds
.
Datastore
,
privkey
ci
.
PrivKey
)
routing
.
IpfsRouting
{
return
&
offlineRouting
{
datastore
:
dstore
,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论