Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
b61b281e
提交
b61b281e
authored
12月 18, 2014
作者:
Juan Batiz-Benet
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
net/conns better printing of connections
上级
8b4c7cf3
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
36 行增加
和
18 行删除
+36
-18
mux.go
net/mux.go
+1
-1
net.go
net/net.go
+4
-0
net_test.go
net/net_test.go
+27
-17
swarm_conn.go
net/swarm/swarm_conn.go
+4
-0
没有找到文件。
net/mux.go
浏览文件 @
b61b281e
...
...
@@ -11,7 +11,7 @@ import (
lgbl
"github.com/jbenet/go-ipfs/util/eventlog/loggables"
)
var
log
=
eventlog
.
Logger
(
"
mux2
"
)
var
log
=
eventlog
.
Logger
(
"
network
"
)
// Mux provides simple stream multixplexing.
// It helps you precisely when:
...
...
net/net.go
浏览文件 @
b61b281e
...
...
@@ -42,6 +42,10 @@ func (s *stream) Write(p []byte) (n int, err error) {
type
conn_
swarm
.
Conn
func
(
s
*
conn_
)
String
()
string
{
return
s
.
SwarmConn
()
.
String
()
}
func
(
c
*
conn_
)
SwarmConn
()
*
swarm
.
Conn
{
return
(
*
swarm
.
Conn
)(
c
)
}
...
...
net/net_test.go
浏览文件 @
b61b281e
package
net_test
import
(
"fmt"
"testing"
context
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context"
...
...
@@ -34,28 +35,37 @@ func TestConnectednessCorrect(t *testing.T) {
// test those connected show up correctly
testConnectedness
:=
func
(
a
,
b
inet
.
Network
,
c
inet
.
Connectedness
)
{
if
a
.
Connectedness
(
b
.
LocalPeer
())
!=
c
{
t
.
Error
(
"%s is connected to %s, but Connectedness incorrect"
,
a
,
b
)
}
// test symmetric case
if
b
.
Connectedness
(
a
.
LocalPeer
())
!=
c
{
t
.
Error
(
"%s is connected to %s, but Connectedness incorrect"
,
a
,
b
)
}
}
// test connected
testConnectedness
(
nets
[
0
],
nets
[
1
],
inet
.
Connected
)
testConnectedness
(
nets
[
0
],
nets
[
3
],
inet
.
Connected
)
testConnectedness
(
nets
[
1
],
nets
[
2
],
inet
.
Connected
)
testConnectedness
(
nets
[
3
],
nets
[
2
],
inet
.
Connected
)
testConnectedness
(
t
,
nets
[
0
],
nets
[
1
],
inet
.
Connected
)
testConnectedness
(
t
,
nets
[
0
],
nets
[
3
],
inet
.
Connected
)
testConnectedness
(
t
,
nets
[
1
],
nets
[
2
],
inet
.
Connected
)
testConnectedness
(
t
,
nets
[
3
],
nets
[
2
],
inet
.
Connected
)
// test not connected
testConnectedness
(
nets
[
0
],
nets
[
2
],
inet
.
NotConnected
)
testConnectedness
(
nets
[
1
],
nets
[
3
],
inet
.
NotConnected
)
testConnectedness
(
t
,
nets
[
0
],
nets
[
2
],
inet
.
NotConnected
)
testConnectedness
(
t
,
nets
[
1
],
nets
[
3
],
inet
.
NotConnected
)
for
_
,
n
:=
range
nets
{
n
.
Close
()
}
}
func
testConnectedness
(
t
*
testing
.
T
,
a
,
b
inet
.
Network
,
c
inet
.
Connectedness
)
{
es
:=
"%s is connected to %s, but Connectedness incorrect. %s %s"
if
a
.
Connectedness
(
b
.
LocalPeer
())
!=
c
{
t
.
Errorf
(
es
,
a
,
b
,
printConns
(
a
),
printConns
(
b
))
}
// test symmetric case
if
b
.
Connectedness
(
a
.
LocalPeer
())
!=
c
{
t
.
Errorf
(
es
,
b
,
a
,
printConns
(
b
),
printConns
(
a
))
}
}
func
printConns
(
n
inet
.
Network
)
string
{
s
:=
fmt
.
Sprintf
(
"Connections in %s:
\n
"
,
n
)
for
_
,
c
:=
range
n
.
Conns
()
{
s
=
s
+
fmt
.
Sprintf
(
"- %s
\n
"
,
c
)
}
return
s
}
net/swarm/swarm_conn.go
浏览文件 @
b61b281e
...
...
@@ -40,6 +40,10 @@ func (c *Conn) RawConn() conn.Conn {
return
(
*
ps
.
Conn
)(
c
)
.
NetConn
()
.
(
conn
.
Conn
)
}
func
(
c
*
Conn
)
String
()
string
{
return
fmt
.
Sprintf
(
"<SwarmConn %s>"
,
c
.
RawConn
())
}
// LocalMultiaddr is the Multiaddr on this side
func
(
c
*
Conn
)
LocalMultiaddr
()
ma
.
Multiaddr
{
return
c
.
RawConn
()
.
LocalMultiaddr
()
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论