Commit b0a36aab authored by Juan Batiz-Benet's avatar Juan Batiz-Benet

mocknet: bugfix on opening conns + printer

parent f1fc09cc
......@@ -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) {
......
......@@ -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)
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment