mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 01:43:16 +01:00
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:
parent
e2fe4c2955
commit
000a83bc04
15
server.go
15
server.go
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user