server: fetch addr from db if outbound too
This commit just ensures that we fetch the lastest advertised addresses for a peer from the db for both inbound and outbound peers. The reason for seperating this into its own commit is to make future commits in this PR easier to review.
This commit is contained in:
1 file changed
+6
-2
@@ -3531,7 +3531,6 @@ func (s *server) peerTerminationWatcher(p *peer.Brontide, ready chan struct{}) {
|
|||||||
// within the peer's address for reconnection purposes.
|
// within the peer's address for reconnection purposes.
|
||||||
//
|
//
|
||||||
// TODO(roasbeef): use them all?
|
// TODO(roasbeef): use them all?
|
||||||
if p.Inbound() {
|
|
||||||
advertisedAddr, err := s.fetchNodeAdvertisedAddr(pubKey)
|
advertisedAddr, err := s.fetchNodeAdvertisedAddr(pubKey)
|
||||||
switch {
|
switch {
|
||||||
// We found an advertised address, so use it.
|
// We found an advertised address, so use it.
|
||||||
@@ -3540,6 +3539,12 @@ func (s *server) peerTerminationWatcher(p *peer.Brontide, ready chan struct{}) {
|
|||||||
|
|
||||||
// The peer doesn't have an advertised address.
|
// The peer doesn't have an advertised address.
|
||||||
case err == errNoAdvertisedAddr:
|
case err == errNoAdvertisedAddr:
|
||||||
|
// If it is an outbound peer then we fall back to the existing
|
||||||
|
// peer address.
|
||||||
|
if !p.Inbound() {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
// Fall back to the existing peer address if
|
// Fall back to the existing peer address if
|
||||||
// we're not accepting connections over Tor.
|
// we're not accepting connections over Tor.
|
||||||
if s.torController == nil {
|
if s.torController == nil {
|
||||||
@@ -3564,7 +3569,6 @@ func (s *server) peerTerminationWatcher(p *peer.Brontide, ready chan struct{}) {
|
|||||||
"address for node %x: %v", p.PubKey(),
|
"address for node %x: %v", p.PubKey(),
|
||||||
err)
|
err)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Otherwise, we'll launch a new connection request in order to
|
// Otherwise, we'll launch a new connection request in order to
|
||||||
// attempt to maintain a persistent connection with this peer.
|
// attempt to maintain a persistent connection with this peer.
|
||||||
|
|||||||
Reference in new issue
Block a user