From f9f29bbe42ef01f044c264821c98113f125a7de9 Mon Sep 17 00:00:00 2001 From: Matthias Radestock Date: Wed, 12 Nov 2014 19:24:06 +0000 Subject: [PATCH] refactor: reduce indent --- router/peer.go | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/router/peer.go b/router/peer.go index a42db164..6c08afd3 100644 --- a/router/peer.go +++ b/router/peer.go @@ -286,23 +286,22 @@ func (peer *Peer) handleAddConnection(conn *LocalConnection) { if dupConn, found := peer.connections[toName]; found { if dupConn == conn { return + } + // conn.UID is used as the tie breaker here, in the + // knowledge that both sides will make the same decision. + dupConnLocal := dupConn.(*LocalConnection) + if conn.UID == dupConnLocal.UID { + // oh good grief. Sod it, just kill both of them. + conn.CheckFatal(dupErr) + dupConnLocal.CheckFatal(dupErr) + peer.handleDeleteConnection(dupConnLocal) + return + } else if conn.UID < dupConnLocal.UID { + dupConnLocal.CheckFatal(dupErr) + peer.handleDeleteConnection(dupConnLocal) } else { - // conn.UID is used as the tie breaker here, in the - // knowledge that both sides will make the same decision. - dupConnLocal := dupConn.(*LocalConnection) - if conn.UID == dupConnLocal.UID { - // oh good grief. Sod it, just kill both of them. - conn.CheckFatal(dupErr) - dupConnLocal.CheckFatal(dupErr) - peer.handleDeleteConnection(dupConnLocal) - return - } else if conn.UID < dupConnLocal.UID { - dupConnLocal.CheckFatal(dupErr) - peer.handleDeleteConnection(dupConnLocal) - } else { - conn.CheckFatal(dupErr) - return - } + conn.CheckFatal(dupErr) + return } } if err := peer.checkConnectionLimit(); err != nil {