Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
78c0802f
提交
78c0802f
authored
12月 16, 2014
作者:
Juan Batiz-Benet
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
connect swarm context to network
上级
ba323c3e
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
5 行增加
和
10 行删除
+5
-10
net.go
net/net.go
+1
-5
simul_test.go
net/swarm2/simul_test.go
+1
-1
swarm.go
net/swarm2/swarm.go
+1
-1
swarm_dial.go
net/swarm2/swarm_dial.go
+1
-2
swarm_test.go
net/swarm2/swarm_test.go
+1
-1
没有找到文件。
net/net.go
浏览文件 @
78c0802f
...
...
@@ -4,7 +4,6 @@ package net
import
(
swarm
"github.com/jbenet/go-ipfs/net/swarm2"
peer
"github.com/jbenet/go-ipfs/peer"
util
"github.com/jbenet/go-ipfs/util"
context
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context"
ctxgroup
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-ctxgroup"
...
...
@@ -117,10 +116,7 @@ func NewNetwork(ctx context.Context, listen []ma.Multiaddr, local peer.Peer,
// DialPeer attempts to establish a connection to a given peer.
// Respects the context.
func
(
n
*
network
)
DialPeer
(
ctx
context
.
Context
,
p
peer
.
Peer
)
error
{
err
:=
util
.
ContextDo
(
ctx
,
func
()
error
{
_
,
err
:=
n
.
swarm
.
Dial
(
p
)
return
err
})
_
,
err
:=
n
.
swarm
.
Dial
(
ctx
,
p
)
return
err
}
...
...
net/swarm2/simul_test.go
浏览文件 @
78c0802f
...
...
@@ -30,7 +30,7 @@ func TestSimultOpen(t *testing.T) {
cp
:=
testutil
.
NewPeerWithID
(
dst
.
ID
())
cp
.
AddAddress
(
dst
.
Addresses
()[
0
])
if
_
,
err
:=
s
.
Dial
(
cp
);
err
!=
nil
{
if
_
,
err
:=
s
.
Dial
(
c
tx
,
c
p
);
err
!=
nil
{
t
.
Fatal
(
"error swarm dialing to peer"
,
err
)
}
wg
.
Done
()
...
...
net/swarm2/swarm.go
浏览文件 @
78c0802f
...
...
@@ -90,7 +90,7 @@ func (s *Swarm) NewStreamWithPeer(p peer.Peer) (*Stream, error) {
// if we have no connections, try connecting.
if
len
(
s
.
ConnectionsToPeer
(
p
))
==
0
{
log
.
Debug
(
"Swarm: NewStreamWithPeer no connections. Attempting to connect..."
)
if
_
,
err
:=
s
.
Dial
(
p
);
err
!=
nil
{
if
_
,
err
:=
s
.
Dial
(
context
.
Background
(),
p
);
err
!=
nil
{
return
nil
,
err
}
}
...
...
net/swarm2/swarm_dial.go
浏览文件 @
78c0802f
...
...
@@ -17,8 +17,7 @@ import (
// the connection will happen over. Swarm can use whichever it choses.
// This allows us to use various transport protocols, do NAT traversal/relay,
// etc. to achive connection.
func
(
s
*
Swarm
)
Dial
(
p
peer
.
Peer
)
(
*
Conn
,
error
)
{
ctx
:=
context
.
TODO
()
func
(
s
*
Swarm
)
Dial
(
ctx
context
.
Context
,
p
peer
.
Peer
)
(
*
Conn
,
error
)
{
if
p
.
ID
()
.
Equal
(
s
.
local
.
ID
())
{
return
nil
,
errors
.
New
(
"Attempted connection to self!"
)
...
...
net/swarm2/swarm_test.go
浏览文件 @
78c0802f
...
...
@@ -108,7 +108,7 @@ func SubtestSwarm(t *testing.T, addrs []string, MsgNum int) {
cp
.
AddAddress
(
dst
.
Addresses
()[
0
])
log
.
Infof
(
"SWARM TEST: %s dialing %s"
,
s
.
local
,
dst
)
if
_
,
err
:=
s
.
Dial
(
cp
);
err
!=
nil
{
if
_
,
err
:=
s
.
Dial
(
c
tx
,
c
p
);
err
!=
nil
{
t
.
Fatal
(
"error swarm dialing to peer"
,
err
)
}
log
.
Infof
(
"SWARM TEST: %s connected to %s"
,
s
.
local
,
dst
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论