|
@ -137,17 +137,20 @@ func (sw *Switch) DialPeerWithAddress(addr *NetAddress) (*Peer, error) { |
|
|
return nil, ErrSwitchStopped |
|
|
return nil, ErrSwitchStopped |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
log.Info("Dialing peer", "address", addr) |
|
|
|
|
|
|
|
|
log.Debug("Dialing address", "address", addr) |
|
|
sw.dialing.Set(addr.String(), addr) |
|
|
sw.dialing.Set(addr.String(), addr) |
|
|
conn, err := addr.DialTimeout(peerDialTimeoutSeconds * time.Second) |
|
|
conn, err := addr.DialTimeout(peerDialTimeoutSeconds * time.Second) |
|
|
sw.dialing.Delete(addr.String()) |
|
|
sw.dialing.Delete(addr.String()) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
|
|
|
log.Debug("Failed dialing address", "address", addr, "error", err) |
|
|
return nil, err |
|
|
return nil, err |
|
|
} |
|
|
} |
|
|
peer, err := sw.AddPeerWithConnection(conn, true) |
|
|
peer, err := sw.AddPeerWithConnection(conn, true) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
|
|
|
log.Debug("Failed adding peer", "address", addr, "conn", conn, "error", err) |
|
|
return nil, err |
|
|
return nil, err |
|
|
} |
|
|
} |
|
|
|
|
|
log.Info("Dialed and added peer", "address", addr, "peer", peer) |
|
|
return peer, nil |
|
|
return peer, nil |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|