Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-unixfs
Commits
b0a36aab
Commit
b0a36aab
authored
Dec 17, 2014
by
Juan Batiz-Benet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mocknet: bugfix on opening conns + printer
parent
f1fc09cc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
3 deletions
+9
-3
net/mock/mock_link.go
net/mock/mock_link.go
+6
-2
net/mock/mock_peernet.go
net/mock/mock_peernet.go
+3
-1
No files found.
net/mock/mock_link.go
View file @
b0a36aab
...
...
@@ -23,7 +23,7 @@ func newLink(mn *mocknet, opts LinkOptions) *link {
return
&
link
{
mock
:
mn
,
opts
:
opts
}
}
func
(
l
*
link
)
newConnPair
()
(
*
conn
,
*
conn
)
{
func
(
l
*
link
)
newConnPair
(
dialer
*
peernet
)
(
*
conn
,
*
conn
)
{
l
.
RLock
()
defer
l
.
RUnlock
()
...
...
@@ -43,7 +43,11 @@ func (l *link) newConnPair() (*conn, *conn) {
c2
:=
mkconn
(
l
.
nets
[
1
],
l
.
nets
[
0
]
.
peer
.
ID
())
c1
.
rconn
=
c2
c2
.
rconn
=
c1
return
c1
,
c2
if
dialer
==
c1
.
net
{
return
c1
,
c2
}
return
c2
,
c1
}
func
(
l
*
link
)
newStreamPair
()
(
*
stream
,
*
stream
)
{
...
...
net/mock/mock_peernet.go
View file @
b0a36aab
...
...
@@ -137,13 +137,15 @@ func (pn *peernet) connect(p peer.Peer) error {
}
func
(
pn
*
peernet
)
openConn
(
r
peer
.
Peer
,
l
*
link
)
*
conn
{
lc
,
rc
:=
l
.
newConnPair
()
lc
,
rc
:=
l
.
newConnPair
(
pn
)
log
.
Debugf
(
"%s opening connection to %s"
,
pn
.
LocalPeer
(),
lc
.
RemotePeer
())
pn
.
addConn
(
lc
)
rc
.
net
.
remoteOpenedConn
(
rc
)
return
lc
}
func
(
pn
*
peernet
)
remoteOpenedConn
(
c
*
conn
)
{
log
.
Debugf
(
"%s accepting connection from %s"
,
pn
.
LocalPeer
(),
c
.
RemotePeer
())
pn
.
addConn
(
c
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment