Skip to content

Commit 7e1f6f5

Browse files
committed
misc: fix lint
1 parent 720f0a0 commit 7e1f6f5

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

channeldb/graph.go

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,10 @@ func (g *ChannelGraph) populateGraphCache() {
289289
return
290290
}
291291

292-
log.Debugf("Finished populating in-memory channel graph (took "+
293-
"%v, %s)", time.Since(startTime), g.graphCache.Stats())
292+
if g.graphCache != nil {
293+
log.Debugf("Finished populating in-memory channel graph (took "+
294+
"%v, %s)", time.Since(startTime), g.graphCache.Stats())
295+
}
294296

295297
g.graphCacheReady.Store(true)
296298
}
@@ -898,16 +900,18 @@ func (c *ChannelGraph) AddLightningNode(node *LightningNode,
898900
Update: func(tx kvdb.RwTx) error {
899901
graphCache, err := c.getGraphCache()
900902
if err != nil {
901-
if err == ErrGraphCacheNotReady {
903+
if errors.Is(err, ErrGraphCacheNotReady) {
902904
// Queue this update function
903905
c.enqueueWriteOperation(func() error {
904906
return c.AddLightningNode(
905907
node,
906908
op...,
907909
)
908910
})
911+
909912
return nil
910913
}
914+
911915
return err
912916
}
913917

@@ -917,6 +921,7 @@ func (c *ChannelGraph) AddLightningNode(node *LightningNode,
917921
)
918922
err := graphCache.AddNode(tx, cNode)
919923
if err != nil {
924+
920925
return err
921926
}
922927
}
@@ -1001,7 +1006,7 @@ func (c *ChannelGraph) DeleteLightningNode(nodePub route.Vertex) error {
10011006

10021007
graphCache, err := c.getGraphCache()
10031008
if err != nil {
1004-
if err == ErrGraphCacheNotReady {
1009+
if errors.Is(err, ErrGraphCacheNotReady) {
10051010
// Queue this delete function
10061011
c.enqueueWriteOperation(func() error {
10071012
return c.DeleteLightningNode(nodePub)
@@ -1144,7 +1149,7 @@ func (c *ChannelGraph) addChannelEdge(tx kvdb.RwTx,
11441149

11451150
graphCache, err := c.getGraphCache()
11461151
if err != nil {
1147-
if err == ErrGraphCacheNotReady {
1152+
if errors.Is(err, ErrGraphCacheNotReady) {
11481153
// Queue this function
11491154
c.enqueueWriteOperation(func() error {
11501155
return c.addChannelEdge(tx, edge)
@@ -1359,7 +1364,7 @@ func (c *ChannelGraph) UpdateChannelEdge(edge *models.ChannelEdgeInfo) error {
13591364

13601365
graphCache, err := c.getGraphCache()
13611366
if err != nil {
1362-
if err == ErrGraphCacheNotReady {
1367+
if errors.Is(err, ErrGraphCacheNotReady) {
13631368
// Queue this update function
13641369
c.enqueueWriteOperation(func() error {
13651370
return c.UpdateChannelEdge(edge)
@@ -1606,7 +1611,7 @@ func (c *ChannelGraph) pruneGraphNodes(nodes kvdb.RwBucket,
16061611

16071612
graphCache, err := c.getGraphCache()
16081613
if err != nil {
1609-
if err == ErrGraphCacheNotReady {
1614+
if errors.Is(err, ErrGraphCacheNotReady) {
16101615
// Queue this prune operation
16111616
c.enqueueWriteOperation(func() error {
16121617
return c.pruneGraphNodes(nodes, edgeIndex)
@@ -2660,7 +2665,7 @@ func (c *ChannelGraph) delChannelEdgeUnsafe(edges, edgeIndex, chanIndex,
26602665

26612666
graphCache, err := c.getGraphCache()
26622667
if err != nil {
2663-
if err == ErrGraphCacheNotReady {
2668+
if errors.Is(err, ErrGraphCacheNotReady) {
26642669
// Queue this delete function
26652670
c.enqueueWriteOperation(func() error {
26662671
return c.delChannelEdgeUnsafe(edges, edgeIndex, chanIndex, zombieIndex, chanID, isZombie, strictZombie)
@@ -2929,7 +2934,7 @@ func updateEdgePolicy(tx kvdb.RwTx, edge *models.ChannelEdgePolicy,
29292934

29302935
graphCache, err := c.getGraphCache()
29312936
if err != nil {
2932-
if err == ErrGraphCacheNotReady {
2937+
if errors.Is(err, ErrGraphCacheNotReady) {
29332938
// Queue this update function
29342939
c.enqueueWriteOperation(func() error {
29352940
_, err := updateEdgePolicy(tx, edge, c)
@@ -3822,7 +3827,7 @@ func (c *ChannelGraph) MarkEdgeZombie(chanID uint64,
38223827

38233828
graphCache, err := c.getGraphCache()
38243829
if err != nil {
3825-
if err == ErrGraphCacheNotReady {
3830+
if errors.Is(err, ErrGraphCacheNotReady) {
38263831
// Queue this function
38273832
c.enqueueWriteOperation(func() error {
38283833
return c.MarkEdgeZombie(chanID, pubKey1, pubKey2)
@@ -3918,7 +3923,7 @@ func (c *ChannelGraph) markEdgeLiveUnsafe(tx kvdb.RwTx, chanID uint64) error {
39183923
// won't use it for path finding.
39193924
graphCache, err := c.getGraphCache()
39203925
if err != nil {
3921-
if err == ErrGraphCacheNotReady {
3926+
if errors.Is(err, ErrGraphCacheNotReady) {
39223927
// Queue the operation to add the channel back.
39233928
c.enqueueWriteOperation(func() error {
39243929
return c.markEdgeLiveUnsafe(tx, chanID)

0 commit comments

Comments
 (0)