server: add bootstrap peers to persistent peers for conn retry

Peers are treated as transient by default. When a peer is disconnected,
no attempt is made to reconnect. However, if we have a channel open
with a peer that peer will be added as persistent. If a persistent peer
becomes disconnected then we will attempt to reconnect.

This behavior implies that a fresh node - those without any channels -
will fall off the network over time as remote nodes restart or due to
connectivity changes. This change marks bootstrap peers as persistent
and ensures that the node remains connected to those specific peers over
time. This does not keep the node connected in the case that all
bootstrap peers are down.

Fixes #451.
This commit is contained in:
Brian KimJohnson 2018-01-05 23:37:31 -05:00 committed by Olaoluwa Osuntokun
parent e2fe4c2955
commit 000a83bc04
1 changed files with 15 additions and 0 deletions

View File

@ -570,6 +570,13 @@ func (s *server) peerBootstrapper(numTargetPeers uint32,
return
}
// Add bootstrapped peer as persistent to maintain
// connectivity even if we have no open channels.
targetPub := string(conn.RemotePub().SerializeCompressed())
s.mu.Lock()
s.persistentPeers[targetPub] = struct{}{}
s.mu.Unlock()
s.OutboundPeerConnected(nil, conn)
}(addr)
}
@ -673,6 +680,14 @@ func (s *server) peerBootstrapper(numTargetPeers uint32,
atomic.AddUint32(&epochErrors, 1)
return
}
// Add bootstrapped peer as persistent to maintain
// connectivity even if we have no open channels.
targetPub := string(conn.RemotePub().SerializeCompressed())
s.mu.Lock()
s.persistentPeers[targetPub] = struct{}{}
s.mu.Unlock()
s.OutboundPeerConnected(nil, conn)
}(addr)
}