server: defer cancelling the outbound connection until the tie-breaker
This commit is contained in:
parent
179b25c580
commit
8885c3de8d
@ -3184,7 +3184,6 @@ func (lc *LightningChannel) ProcessChanSyncMsg(
|
|||||||
// revocation, but also initiate a state transition to re-sync
|
// revocation, but also initiate a state transition to re-sync
|
||||||
// them.
|
// them.
|
||||||
if !lc.FullySynced() {
|
if !lc.FullySynced() {
|
||||||
|
|
||||||
commitSig, htlcSigs, err := lc.SignNextCommitment()
|
commitSig, htlcSigs, err := lc.SignNextCommitment()
|
||||||
switch {
|
switch {
|
||||||
|
|
||||||
|
12
server.go
12
server.go
@ -1545,6 +1545,9 @@ func (s *server) peerConnected(conn net.Conn, connReq *connmgr.ConnReq,
|
|||||||
addr := conn.RemoteAddr()
|
addr := conn.RemoteAddr()
|
||||||
pubKey := brontideConn.RemotePub()
|
pubKey := brontideConn.RemotePub()
|
||||||
|
|
||||||
|
srvrLog.Infof("finalizing connection to %x, inbound=%v",
|
||||||
|
pubKey.SerializeCompressed(), inbound)
|
||||||
|
|
||||||
peerAddr := &lnwire.NetAddress{
|
peerAddr := &lnwire.NetAddress{
|
||||||
IdentityKey: pubKey,
|
IdentityKey: pubKey,
|
||||||
Address: addr,
|
Address: addr,
|
||||||
@ -1641,12 +1644,6 @@ func (s *server) InboundPeerConnected(conn net.Conn) {
|
|||||||
|
|
||||||
srvrLog.Infof("New inbound connection from %v", conn.RemoteAddr())
|
srvrLog.Infof("New inbound connection from %v", conn.RemoteAddr())
|
||||||
|
|
||||||
// Cancel all pending connection requests, we either already have an
|
|
||||||
// outbound connection, or this incoming connection will become our
|
|
||||||
// primary connection. The incoming connection will not have an
|
|
||||||
// associated connection request, so we pass nil.
|
|
||||||
s.cancelConnReqs(pubStr, nil)
|
|
||||||
|
|
||||||
// Check to see if we already have a connection with this peer. If so,
|
// Check to see if we already have a connection with this peer. If so,
|
||||||
// we may need to drop our existing connection. This prevents us from
|
// we may need to drop our existing connection. This prevents us from
|
||||||
// having duplicate connections to the same peer. We forgo adding a
|
// having duplicate connections to the same peer. We forgo adding a
|
||||||
@ -1657,6 +1654,7 @@ func (s *server) InboundPeerConnected(conn net.Conn) {
|
|||||||
case ErrPeerNotConnected:
|
case ErrPeerNotConnected:
|
||||||
// We were unable to locate an existing connection with the
|
// We were unable to locate an existing connection with the
|
||||||
// target peer, proceed to connect.
|
// target peer, proceed to connect.
|
||||||
|
s.cancelConnReqs(pubStr, nil)
|
||||||
s.peerConnected(conn, nil, true)
|
s.peerConnected(conn, nil, true)
|
||||||
|
|
||||||
case nil:
|
case nil:
|
||||||
@ -1678,6 +1676,8 @@ func (s *server) InboundPeerConnected(conn net.Conn) {
|
|||||||
srvrLog.Debugf("Disconnecting stale connection to %v",
|
srvrLog.Debugf("Disconnecting stale connection to %v",
|
||||||
connectedPeer)
|
connectedPeer)
|
||||||
|
|
||||||
|
s.cancelConnReqs(pubStr, nil)
|
||||||
|
|
||||||
// Remove the current peer from the server's internal state and
|
// Remove the current peer from the server's internal state and
|
||||||
// signal that the peer termination watcher does not need to
|
// signal that the peer termination watcher does not need to
|
||||||
// execute for this peer.
|
// execute for this peer.
|
||||||
|
Loading…
Reference in New Issue
Block a user