@@ -701,7 +701,7 @@ func (p *PeerConnManager) EstablishPersistentConnections() error {
701
701
// the reconnection port to the default peer port.
702
702
linkNodes , err := p .Config .PartialPeerConfig .ChannelDB .LinkNodeDB ().
703
703
FetchAllLinkNodes ()
704
- if err != nil && err != channeldb .ErrLinkNodesNotFound {
704
+ if err != nil && ! errors . Is ( err , channeldb .ErrLinkNodesNotFound ) {
705
705
return err
706
706
}
707
707
for _ , node := range linkNodes {
@@ -802,7 +802,7 @@ func (p *PeerConnManager) EstablishPersistentConnections() error {
802
802
nodeAddrsMap [pubStr ] = n
803
803
return nil
804
804
})
805
- if err != nil && err != channeldb .ErrGraphNoEdgesFound {
805
+ if err != nil && ! errors . Is ( err , channeldb .ErrGraphNoEdgesFound ) {
806
806
return err
807
807
}
808
808
@@ -1182,14 +1182,14 @@ func (p *PeerConnManager) InboundPeerConnected(conn net.Conn) {
1182
1182
// default case as we expect these to be the only error values returned
1183
1183
// from findPeerByPubStr.
1184
1184
connectedPeer , err := p .findPeerByPubStr (pubStr )
1185
- switch err {
1186
- case ErrPeerNotConnected :
1185
+ switch {
1186
+ case errors . Is ( err , ErrPeerNotConnected ) :
1187
1187
// We were unable to locate an existing connection with the
1188
1188
// target peer, proceed to connect.
1189
1189
p .cancelConnReqs (pubStr , nil )
1190
1190
p .peerConnected (conn , nil , true )
1191
1191
1192
- case nil :
1192
+ case err == nil :
1193
1193
// We already have a connection with the incoming peer. If the
1194
1194
// connection we've already established should be kept and is
1195
1195
// not of the same type of the new connection (inbound), then
@@ -1296,13 +1296,13 @@ func (p *PeerConnManager) OutboundPeerConnected(connReq *connmgr.ConnReq,
1296
1296
// as we expect these to be the only error values returned from
1297
1297
// findPeerByPubStr.
1298
1298
connectedPeer , err := p .findPeerByPubStr (pubStr )
1299
- switch err {
1300
- case ErrPeerNotConnected :
1299
+ switch {
1300
+ case errors . Is ( err , ErrPeerNotConnected ) :
1301
1301
// We were unable to locate an existing connection with the
1302
1302
// target peer, proceed to connect.
1303
1303
p .peerConnected (conn , connReq , false )
1304
1304
1305
- case nil :
1305
+ case err == nil :
1306
1306
// We already have a connection with the incoming peer. If the
1307
1307
// connection we've already established should be kept and is
1308
1308
// not of the same type of the new connection (outbound), then
@@ -1540,7 +1540,7 @@ func (p *PeerConnManager) peerInitializer(peer *peer.Brontide) {
1540
1540
// Start the peer! If an error occurs, we Disconnect the peer, which
1541
1541
// will unblock the peerTerminationWatcher.
1542
1542
if err := peer .Start (); err != nil {
1543
- peer .Disconnect (fmt .Errorf ("unable to start peer: %v " , err ))
1543
+ peer .Disconnect (fmt .Errorf ("unable to start peer: %w " , err ))
1544
1544
return
1545
1545
}
1546
1546
@@ -1676,7 +1676,7 @@ func (p *PeerConnManager) peerTerminationWatcher(peer *peer.Brontide,
1676
1676
addrs = advertisedAddrs
1677
1677
1678
1678
// The peer doesn't have an advertised address.
1679
- case err == errNoAdvertisedAddr :
1679
+ case errors . Is ( err , errNoAdvertisedAddr ) :
1680
1680
// If it is an outbound peer then we fall back to the existing
1681
1681
// peer address.
1682
1682
if ! peer .Inbound () {
@@ -2031,7 +2031,7 @@ func (p *PeerConnManager) DisconnectPeer(pubKey *btcec.PublicKey) error {
2031
2031
// exit in an error as we can't disconnect from a peer that we're not
2032
2032
// currently connected to.
2033
2033
peer , err := p .findPeerByPubStr (pubStr )
2034
- if err == ErrPeerNotConnected {
2034
+ if errors . Is ( err , ErrPeerNotConnected ) {
2035
2035
return fmt .Errorf ("peer %x is not connected" , pubBytes )
2036
2036
}
2037
2037
0 commit comments