p2p/simulations: LiveEvents DidConnect and DidDisconnect use GetOrCreateConn

This commit is contained in:
Fabio Barone 2017-04-29 09:40:23 -05:00 committed by Lewis Marshall
parent c86d0f4d25
commit a4b52df32c

View file

@ -700,8 +700,8 @@ func (self *Network) Disconnect(oneId, otherId *adapters.NodeId) error {
} }
func (self *Network) DidConnect(one, other *adapters.NodeId) error { func (self *Network) DidConnect(one, other *adapters.NodeId) error {
conn := self.GetConn(one, other) conn, err := self.GetOrCreateConn(one, other)
if conn == nil { if err != nil {
return fmt.Errorf("connection between %v and %v does not exist", one, other) return fmt.Errorf("connection between %v and %v does not exist", one, other)
} }
if conn.Up { if conn.Up {
@ -715,8 +715,8 @@ func (self *Network) DidConnect(one, other *adapters.NodeId) error {
} }
func (self *Network) DidDisconnect(one, other *adapters.NodeId) error { func (self *Network) DidDisconnect(one, other *adapters.NodeId) error {
conn := self.GetConn(one, other) conn, err := self.GetOrCreateConn(one, other)
if conn == nil { if err != nil {
return fmt.Errorf("connection between %v and %v does not exist", one, other) return fmt.Errorf("connection between %v and %v does not exist", one, other)
} }
if !conn.Up { if !conn.Up {