Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
31a3c449
提交
31a3c449
authored
12月 16, 2014
作者:
Juan Batiz-Benet
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
swarm fixes
上级
b5b4390c
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
21 行增加
和
10 行删除
+21
-10
simul_test.go
net/swarm2/simul_test.go
+4
-4
swarm.go
net/swarm2/swarm.go
+8
-0
swarm_conn.go
net/swarm2/swarm_conn.go
+5
-5
swarm_listen.go
net/swarm2/swarm_listen.go
+4
-1
没有找到文件。
net/swarm2/simul_test.go
浏览文件 @
31a3c449
...
...
@@ -12,7 +12,7 @@ import (
)
func
TestSimultOpen
(
t
*
testing
.
T
)
{
t
.
Skip
(
"skipping for another test"
)
//
t.Skip("skipping for another test")
addrs
:=
[]
string
{
"/ip4/127.0.0.1/tcp/1244"
,
...
...
@@ -49,9 +49,9 @@ func TestSimultOpen(t *testing.T) {
}
func
TestSimultOpenMany
(
t
*
testing
.
T
)
{
t
.
Skip
(
"very very slow"
)
//
t.Skip("very very slow")
many
:=
50
0
many
:=
1
0
addrs
:=
[]
string
{}
for
i
:=
2200
;
i
<
(
2200
+
many
);
i
++
{
s
:=
fmt
.
Sprintf
(
"/ip4/127.0.0.1/tcp/%d"
,
i
)
...
...
@@ -65,7 +65,7 @@ func TestSimultOpenFewStress(t *testing.T) {
if
testing
.
Short
()
{
t
.
SkipNow
()
}
t
.
Skip
(
"skipping for another test"
)
//
t.Skip("skipping for another test")
num
:=
10
// num := 100
...
...
net/swarm2/swarm.go
浏览文件 @
31a3c449
...
...
@@ -70,6 +70,14 @@ func (s *Swarm) SetStreamHandler(handler StreamHandler) {
// NewStreamWithPeer creates a new stream on any available connection to p
func
(
s
*
Swarm
)
NewStreamWithPeer
(
p
peer
.
Peer
)
(
*
Stream
,
error
)
{
// if we have no connections, try connecting.
if
len
(
s
.
ConnectionsToPeer
(
p
))
==
0
{
if
_
,
err
:=
s
.
Dial
(
p
);
err
!=
nil
{
return
nil
,
err
}
}
st
,
err
:=
s
.
swarm
.
NewStreamWithGroup
(
p
)
return
wrapStream
(
st
),
err
}
...
...
net/swarm2/swarm_conn.go
浏览文件 @
31a3c449
...
...
@@ -14,11 +14,11 @@ import (
// a Conn is a simple wrapper around a ps.Conn that also exposes
// some of the methods from the underlying conn.Conn.
// There's **five** "layers" to each connection:
//
-
0. the net.Conn - underlying net.Conn (TCP/UDP/UTP/etc)
//
-
1. the manet.Conn - provides multiaddr friendly Conn
//
-
2. the conn.Conn - provides Peer friendly Conn (inc Secure channel)
//
-
3. the peerstream.Conn - provides peerstream / spdysptream happiness
//
-
4. the Conn - abstracts everyting out, exposing only key parts of underlying layers
//
*
0. the net.Conn - underlying net.Conn (TCP/UDP/UTP/etc)
//
*
1. the manet.Conn - provides multiaddr friendly Conn
//
*
2. the conn.Conn - provides Peer friendly Conn (inc Secure channel)
//
*
3. the peerstream.Conn - provides peerstream / spdysptream happiness
//
*
4. the Conn - abstracts everyting out, exposing only key parts of underlying layers
// (I know, this is kinda crazy. it's more historical than a good design. though the
// layers do build up pieces of functionality. and they're all just io.RW :) )
type
Conn
ps
.
Conn
...
...
net/swarm2/swarm_listen.go
浏览文件 @
31a3c449
...
...
@@ -18,12 +18,15 @@ func (s *Swarm) listen(addrs []ma.Multiaddr) error {
for
i
,
addr
:=
range
addrs
{
err
:=
s
.
setupListener
(
addr
)
if
err
!=
nil
{
if
retErr
.
Errors
==
nil
{
retErr
.
Errors
=
make
([]
error
,
len
(
addrs
))
}
retErr
.
Errors
[
i
]
=
err
log
.
Errorf
(
"Failed to listen on: %s - %s"
,
addr
,
err
)
}
}
if
len
(
retErr
.
Errors
)
>
0
{
if
retErr
.
Errors
!=
nil
{
return
retErr
}
return
nil
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论