|
@ -318,14 +318,13 @@ func (sw *Switch) DialPeerWithAddress(addr *NetAddress, persistent bool) (*Peer, |
|
|
defer sw.dialing.Delete(addr.IP.String()) |
|
|
defer sw.dialing.Delete(addr.IP.String()) |
|
|
|
|
|
|
|
|
peer, err := newPeer(addr, sw.reactorsByCh, sw.chDescs, sw.StopPeerForError, sw.config, sw.nodePrivKey) |
|
|
peer, err := newPeer(addr, sw.reactorsByCh, sw.chDescs, sw.StopPeerForError, sw.config, sw.nodePrivKey) |
|
|
if persistent { |
|
|
|
|
|
peer.makePersistent() |
|
|
|
|
|
} |
|
|
|
|
|
if err != nil { |
|
|
if err != nil { |
|
|
log.Info("Failed dialing peer", "address", addr, "error", err) |
|
|
log.Info("Failed dialing peer", "address", addr, "error", err) |
|
|
peer.CloseConn() |
|
|
|
|
|
return nil, err |
|
|
return nil, err |
|
|
} |
|
|
} |
|
|
|
|
|
if persistent { |
|
|
|
|
|
peer.makePersistent() |
|
|
|
|
|
} |
|
|
err = sw.AddPeer(peer) |
|
|
err = sw.AddPeer(peer) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
log.Info("Failed adding peer", "address", addr, "error", err) |
|
|
log.Info("Failed adding peer", "address", addr, "error", err) |
|
@ -549,7 +548,7 @@ func makeSwitch(i int, network, version string, initSwitch func(int, *Switch) *S |
|
|
func (sw *Switch) AddPeerWithConnection(conn net.Conn, outbound bool) error { |
|
|
func (sw *Switch) AddPeerWithConnection(conn net.Conn, outbound bool) error { |
|
|
peer, err := newPeerFromExistingConn(conn, outbound, sw.reactorsByCh, sw.chDescs, sw.StopPeerForError, sw.config, sw.nodePrivKey) |
|
|
peer, err := newPeerFromExistingConn(conn, outbound, sw.reactorsByCh, sw.chDescs, sw.StopPeerForError, sw.config, sw.nodePrivKey) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
peer.CloseConn() |
|
|
|
|
|
|
|
|
conn.Close() |
|
|
return err |
|
|
return err |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|