multi: use the "errors" package everywhere
Replace all usages of the "github.com/go-errors/errors" and "github.com/pkg/errors" packages with the standard lib's "errors" package. This ensures that error wrapping and `errors.Is` checks will work as expected.
This commit is contained in:
44 files changed
+114
-109
No files matched your search
+9
-11
@@ -2,6 +2,7 @@ package graph
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
@@ -9,7 +10,6 @@ import (
|
||||
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/go-errors/errors"
|
||||
"github.com/lightningnetwork/lnd/batch"
|
||||
"github.com/lightningnetwork/lnd/chainntnfs"
|
||||
graphdb "github.com/lightningnetwork/lnd/graph/db"
|
||||
@@ -875,8 +875,8 @@ func (b *Builder) assertNodeAnnFreshness(ctx context.Context, node route.Vertex,
|
||||
// already have.
|
||||
lastUpdate, exists, err := b.cfg.Graph.HasLightningNode(ctx, node)
|
||||
if err != nil {
|
||||
return errors.Errorf("unable to query for the "+
|
||||
"existence of node: %v", err)
|
||||
return fmt.Errorf("unable to query for the "+
|
||||
"existence of node: %w", err)
|
||||
}
|
||||
if !exists {
|
||||
return NewErrf(ErrIgnored, "Ignoring node announcement"+
|
||||
@@ -1004,8 +1004,8 @@ func (b *Builder) addNode(ctx context.Context, node *models.LightningNode,
|
||||
}
|
||||
|
||||
if err := b.cfg.Graph.AddLightningNode(ctx, node, op...); err != nil {
|
||||
return errors.Errorf("unable to add node %x to the "+
|
||||
"graph: %v", node.PubKeyBytes, err)
|
||||
return fmt.Errorf("unable to add node %x to the "+
|
||||
"graph: %w", node.PubKeyBytes, err)
|
||||
}
|
||||
|
||||
log.Tracef("Updated vertex data for node=%x", node.PubKeyBytes)
|
||||
@@ -1051,7 +1051,7 @@ func (b *Builder) addEdge(ctx context.Context, edge *models.ChannelEdgeInfo,
|
||||
edge.ChannelID,
|
||||
)
|
||||
if err != nil && !errors.Is(err, graphdb.ErrGraphNoEdgesFound) {
|
||||
return errors.Errorf("unable to check for edge existence: %v",
|
||||
return fmt.Errorf("unable to check for edge existence: %w",
|
||||
err)
|
||||
}
|
||||
if isZombie {
|
||||
@@ -1109,8 +1109,7 @@ func (b *Builder) addEdge(ctx context.Context, edge *models.ChannelEdgeInfo,
|
||||
|
||||
err = b.cfg.ChainView.UpdateFilter(filterUpdate, b.bestHeight.Load())
|
||||
if err != nil {
|
||||
return errors.Errorf("unable to update chain "+
|
||||
"view: %v", err)
|
||||
return fmt.Errorf("unable to update chain view: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -1152,8 +1151,7 @@ func (b *Builder) updateEdge(ctx context.Context,
|
||||
edge1Timestamp, edge2Timestamp, exists, isZombie, err :=
|
||||
b.cfg.Graph.HasChannelEdge(policy.ChannelID)
|
||||
if err != nil && !errors.Is(err, graphdb.ErrGraphNoEdgesFound) {
|
||||
return errors.Errorf("unable to check for edge existence: %v",
|
||||
err)
|
||||
return fmt.Errorf("unable to check for edge existence: %w", err)
|
||||
}
|
||||
|
||||
// If the channel is marked as a zombie in our database, and
|
||||
@@ -1212,7 +1210,7 @@ func (b *Builder) updateEdge(ctx context.Context,
|
||||
// Now that we know this isn't a stale update, we'll apply the new edge
|
||||
// policy to the proper directional edge within the channel graph.
|
||||
if err = b.cfg.Graph.UpdateEdgePolicy(ctx, policy, op...); err != nil {
|
||||
err := errors.Errorf("unable to add channel: %v", err)
|
||||
err := fmt.Errorf("unable to add channel: %w", err)
|
||||
log.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user