Skip to content

Commit

Permalink
multi: fix linter errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ellemouton committed Nov 8, 2024
1 parent 7edf99f commit fb6c6ba
Show file tree
Hide file tree
Showing 11 changed files with 283 additions and 190 deletions.
9 changes: 6 additions & 3 deletions autopilot/graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package autopilot
import (
"bytes"
"encoding/hex"
"errors"
"net"
"sort"
"sync/atomic"
Expand Down Expand Up @@ -134,7 +135,9 @@ func (d *dbNode) ForEachChannel(cb func(ChannelEdge) error) error {
//
// NOTE: Part of the autopilot.ChannelGraph interface.
func (d *databaseChannelGraph) ForEachNode(cb func(Node) error) error {
return d.db.ForEachNode(func(tx kvdb.RTx, n *models.LightningNode) error {
return d.db.ForEachNode(func(tx kvdb.RTx,
n *models.LightningNode) error {

// We'll skip over any node that doesn't have any advertised
// addresses. As we won't be able to reach them to actually
// open any channels.
Expand Down Expand Up @@ -168,9 +171,9 @@ func (d *databaseChannelGraph) addRandChannel(node1, node2 *btcec.PublicKey,

dbNode, err := d.db.FetchLightningNode(vertex)
switch {
case err == graphdb.ErrGraphNodeNotFound:
case errors.Is(err, graphdb.ErrGraphNodeNotFound):
fallthrough
case err == graphdb.ErrGraphNotFound:
case errors.Is(err, graphdb.ErrGraphNotFound):
graphNode := &models.LightningNode{
HaveNodeAnnouncement: true,
Addresses: []net.Addr{
Expand Down
2 changes: 1 addition & 1 deletion channeldb/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,7 @@ func createLightningNode(priv *btcec.PrivateKey) *models.LightningNode {
AuthSigBytes: testSig.Serialize(),
LastUpdate: time.Unix(updateTime, 0),
Color: color.RGBA{1, 2, 3, 0},
Alias: "kek" + string(pub[:]),
Alias: "kek" + string(pub),
Features: testFeatures,
Addresses: testAddrs,
}
Expand Down
2 changes: 1 addition & 1 deletion discovery/gossiper.go
Original file line number Diff line number Diff line change
Expand Up @@ -1685,7 +1685,7 @@ func (d *AuthenticatedGossiper) retransmitStaleAnns(now time.Time) error {

return nil
})
if err != nil && err != graphdb.ErrGraphNoEdgesFound {
if err != nil && !errors.Is(err, graphdb.ErrGraphNoEdgesFound) {
return fmt.Errorf("unable to retrieve outgoing channels: %w",
err)
}
Expand Down
10 changes: 5 additions & 5 deletions discovery/gossiper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,9 @@ func (r *mockGraphSource) AddProof(chanID lnwire.ShortChannelID,
return nil
}

func (r *mockGraphSource) ForEachNode(func(node *models.LightningNode) error) error {
func (r *mockGraphSource) ForEachNode(
func(node *models.LightningNode) error) error {

return nil
}

Expand Down Expand Up @@ -2318,9 +2320,7 @@ func TestProcessZombieEdgeNowLive(t *testing.T) {

// At this point, the channel should still be considered a zombie.
_, _, _, err = ctx.router.GetChannelByID(chanID)
if err != graphdb.ErrZombieEdge {
t.Fatalf("channel should still be a zombie")
}
require.ErrorIs(t, err, graphdb.ErrZombieEdge)

// Attempting to process the current channel update should fail due to
// its edge being considered a zombie and its timestamp not being within
Expand Down Expand Up @@ -2441,7 +2441,7 @@ func TestReceiveRemoteChannelUpdateFirst(t *testing.T) {
// to the map of premature ChannelUpdates. Check that nothing
// was added to the graph.
chanInfo, e1, e2, err := ctx.router.GetChannelByID(batch.chanUpdAnn1.ShortChannelID)
if err != graphdb.ErrEdgeNotFound {
if !errors.Is(err, graphdb.ErrEdgeNotFound) {
t.Fatalf("Expected ErrEdgeNotFound, got: %v", err)
}
if chanInfo != nil {
Expand Down
Loading

0 comments on commit fb6c6ba

Please sign in to comment.