Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
b2f6c3e3
提交
b2f6c3e3
authored
10月 02, 2018
作者:
Łukasz Magiera
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
coreapi swarm: missing docs, review
License: MIT Signed-off-by:
Łukasz Magiera
<
magik6k@gmail.com
>
上级
6fa2ab0d
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
13 行增加
和
12 行删除
+13
-12
swarm.go
core/commands/swarm.go
+2
-2
swarm.go
core/coreapi/interface/swarm.go
+7
-2
swarm.go
core/coreapi/swarm.go
+4
-8
没有找到文件。
core/commands/swarm.go
浏览文件 @
b2f6c3e3
...
...
@@ -94,7 +94,7 @@ var swarmPeersCmd = &cmds.Command{
}
if
verbose
||
latency
{
lat
,
err
:=
c
.
Latency
(
req
.
Context
)
lat
,
err
:=
c
.
Latency
()
if
err
!=
nil
{
return
err
}
...
...
@@ -106,7 +106,7 @@ var swarmPeersCmd = &cmds.Command{
}
}
if
verbose
||
streams
{
strs
,
err
:=
c
.
Streams
(
req
.
Context
)
strs
,
err
:=
c
.
Streams
()
if
err
!=
nil
{
return
err
}
...
...
core/coreapi/interface/swarm.go
浏览文件 @
b2f6c3e3
...
...
@@ -29,10 +29,10 @@ type ConnectionInfo interface {
Direction
()
net
.
Direction
// Latency returns last known round trip time to the peer
Latency
(
context
.
Context
)
(
time
.
Duration
,
error
)
Latency
()
(
time
.
Duration
,
error
)
// Streams returns list of streams established with the peer
Streams
(
context
.
Context
)
([]
protocol
.
ID
,
error
)
Streams
()
([]
protocol
.
ID
,
error
)
}
// SwarmAPI specifies the interface to libp2p swarm
...
...
@@ -46,7 +46,12 @@ type SwarmAPI interface {
// Peers returns the list of peers we are connected to
Peers
(
context
.
Context
)
([]
ConnectionInfo
,
error
)
// KnownAddrs returns the list of all addresses this node is aware of
KnownAddrs
(
context
.
Context
)
(
map
[
peer
.
ID
][]
ma
.
Multiaddr
,
error
)
// LocalAddrs returns the list of announced listening addresses
LocalAddrs
(
context
.
Context
)
([]
ma
.
Multiaddr
,
error
)
// ListenAddrs returns the list of all listening addresses
ListenAddrs
(
context
.
Context
)
([]
ma
.
Multiaddr
,
error
)
}
core/coreapi/swarm.go
浏览文件 @
b2f6c3e3
...
...
@@ -2,7 +2,6 @@ package coreapi
import
(
"context"
"fmt"
"sort"
"time"
...
...
@@ -37,13 +36,10 @@ func (api *SwarmAPI) Connect(ctx context.Context, pi pstore.PeerInfo) error {
return
coreiface
.
ErrOffline
}
swrm
,
ok
:=
api
.
node
.
PeerHost
.
Network
()
.
(
*
swarm
.
Swarm
)
if
!
ok
{
return
fmt
.
Errorf
(
"peerhost network was not swarm"
)
if
swrm
,
ok
:=
api
.
node
.
PeerHost
.
Network
()
.
(
*
swarm
.
Swarm
);
ok
{
swrm
.
Backoff
()
.
Clear
(
pi
.
ID
)
}
swrm
.
Backoff
()
.
Clear
(
pi
.
ID
)
return
api
.
node
.
PeerHost
.
Connect
(
ctx
,
pi
)
}
...
...
@@ -164,11 +160,11 @@ func (ci *connInfo) Direction() net.Direction {
return
ci
.
dir
}
func
(
ci
*
connInfo
)
Latency
(
context
.
Context
)
(
time
.
Duration
,
error
)
{
func
(
ci
*
connInfo
)
Latency
()
(
time
.
Duration
,
error
)
{
return
ci
.
api
.
node
.
Peerstore
.
LatencyEWMA
(
peer
.
ID
(
ci
.
ID
())),
nil
}
func
(
ci
*
connInfo
)
Streams
(
context
.
Context
)
([]
protocol
.
ID
,
error
)
{
func
(
ci
*
connInfo
)
Streams
()
([]
protocol
.
ID
,
error
)
{
streams
:=
ci
.
conn
.
GetStreams
()
out
:=
make
([]
protocol
.
ID
,
len
(
streams
))
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论