multi: return verbose errors when fetching edges
This commit is contained in:
6 files changed
+27
-24
No files matched your search
+14
-11
@@ -1349,7 +1349,7 @@ func (c *ChannelGraph) PruneGraph(spentOutputs []*wire.OutPoint,
|
|||||||
edges, edgeIndex, chanIndex, zombieIndex,
|
edges, edgeIndex, chanIndex, zombieIndex,
|
||||||
chanID, false, false,
|
chanID, false, false,
|
||||||
)
|
)
|
||||||
if err != nil && err != ErrEdgeNotFound {
|
if err != nil && !errors.Is(err, ErrEdgeNotFound) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1610,7 +1610,7 @@ func (c *ChannelGraph) DisconnectBlockAtHeight(height uint32) (
|
|||||||
edges, edgeIndex, chanIndex, zombieIndex,
|
edges, edgeIndex, chanIndex, zombieIndex,
|
||||||
k, false, false,
|
k, false, false,
|
||||||
)
|
)
|
||||||
if err != nil && err != ErrEdgeNotFound {
|
if err != nil && !errors.Is(err, ErrEdgeNotFound) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2410,7 +2410,7 @@ func (c *ChannelGraph) FetchChanInfos(tx kvdb.RTx, chanIDs []uint64) (
|
|||||||
edgeIndex, cidBytes[:],
|
edgeIndex, cidBytes[:],
|
||||||
)
|
)
|
||||||
switch {
|
switch {
|
||||||
case err == ErrEdgeNotFound:
|
case errors.Is(err, ErrEdgeNotFound):
|
||||||
continue
|
continue
|
||||||
case err != nil:
|
case err != nil:
|
||||||
return err
|
return err
|
||||||
@@ -2667,7 +2667,7 @@ func (c *ChannelGraph) UpdateEdgePolicy(edge *models.ChannelEdgePolicy,
|
|||||||
|
|
||||||
// Silence ErrEdgeNotFound so that the batch can
|
// Silence ErrEdgeNotFound so that the batch can
|
||||||
// succeed, but propagate the error via local state.
|
// succeed, but propagate the error via local state.
|
||||||
if err == ErrEdgeNotFound {
|
if errors.Is(err, ErrEdgeNotFound) {
|
||||||
edgeNotFound = true
|
edgeNotFound = true
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -3323,14 +3323,14 @@ func (c *ChannelGraph) FetchChannelEdgesByOutpoint(op *wire.OutPoint) (
|
|||||||
}
|
}
|
||||||
chanID := chanIndex.Get(b.Bytes())
|
chanID := chanIndex.Get(b.Bytes())
|
||||||
if chanID == nil {
|
if chanID == nil {
|
||||||
return ErrEdgeNotFound
|
return fmt.Errorf("%w: op=%v", ErrEdgeNotFound, op)
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the channel is found to exists, then we'll first retrieve
|
// If the channel is found to exists, then we'll first retrieve
|
||||||
// the general information for the channel.
|
// the general information for the channel.
|
||||||
edge, err := fetchChanEdgeInfo(edgeIndex, chanID)
|
edge, err := fetchChanEdgeInfo(edgeIndex, chanID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return fmt.Errorf("%w: chanID=%x", err, chanID)
|
||||||
}
|
}
|
||||||
edgeInfo = &edge
|
edgeInfo = &edge
|
||||||
|
|
||||||
@@ -3339,7 +3339,7 @@ func (c *ChannelGraph) FetchChannelEdgesByOutpoint(op *wire.OutPoint) (
|
|||||||
// edges.
|
// edges.
|
||||||
e1, e2, err := fetchChanEdgePolicies(edgeIndex, edges, chanID)
|
e1, e2, err := fetchChanEdgePolicies(edgeIndex, edges, chanID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return fmt.Errorf("failed to find policy: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
policy1 = e1
|
policy1 = e1
|
||||||
@@ -3404,7 +3404,7 @@ func (c *ChannelGraph) FetchChannelEdgesByID(chanID uint64) (
|
|||||||
|
|
||||||
// If it doesn't exist, we'll quickly check our zombie index to
|
// If it doesn't exist, we'll quickly check our zombie index to
|
||||||
// see if we've previously marked it as so.
|
// see if we've previously marked it as so.
|
||||||
if err == ErrEdgeNotFound {
|
if errors.Is(err, ErrEdgeNotFound) {
|
||||||
// If the zombie index doesn't exist, or the edge is not
|
// If the zombie index doesn't exist, or the edge is not
|
||||||
// marked as a zombie within it, then we'll return the
|
// marked as a zombie within it, then we'll return the
|
||||||
// original ErrEdgeNotFound error.
|
// original ErrEdgeNotFound error.
|
||||||
@@ -4411,7 +4411,8 @@ func fetchChanEdgePolicies(edgeIndex kvdb.RBucket, edges kvdb.RBucket,
|
|||||||
|
|
||||||
edgeInfo := edgeIndex.Get(chanID)
|
edgeInfo := edgeIndex.Get(chanID)
|
||||||
if edgeInfo == nil {
|
if edgeInfo == nil {
|
||||||
return nil, nil, ErrEdgeNotFound
|
return nil, nil, fmt.Errorf("%w: chanID=%x", ErrEdgeNotFound,
|
||||||
|
chanID)
|
||||||
}
|
}
|
||||||
|
|
||||||
// The first node is contained within the first half of the edge
|
// The first node is contained within the first half of the edge
|
||||||
@@ -4420,7 +4421,8 @@ func fetchChanEdgePolicies(edgeIndex kvdb.RBucket, edges kvdb.RBucket,
|
|||||||
node1Pub := edgeInfo[:33]
|
node1Pub := edgeInfo[:33]
|
||||||
edge1, err := fetchChanEdgePolicy(edges, chanID, node1Pub)
|
edge1, err := fetchChanEdgePolicy(edges, chanID, node1Pub)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, fmt.Errorf("%w: node1Pub=%x", ErrEdgeNotFound,
|
||||||
|
node1Pub)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Similarly, the second node is contained within the latter
|
// Similarly, the second node is contained within the latter
|
||||||
@@ -4428,7 +4430,8 @@ func fetchChanEdgePolicies(edgeIndex kvdb.RBucket, edges kvdb.RBucket,
|
|||||||
node2Pub := edgeInfo[33:66]
|
node2Pub := edgeInfo[33:66]
|
||||||
edge2, err := fetchChanEdgePolicy(edges, chanID, node2Pub)
|
edge2, err := fetchChanEdgePolicy(edges, chanID, node2Pub)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, fmt.Errorf("%w: node2Pub=%x", ErrEdgeNotFound,
|
||||||
|
node2Pub)
|
||||||
}
|
}
|
||||||
|
|
||||||
return edge1, edge2, nil
|
return edge1, edge2, nil
|
||||||
|
|||||||
@@ -2119,7 +2119,7 @@ func (d *AuthenticatedGossiper) isMsgStale(msg lnwire.Message) bool {
|
|||||||
// If the channel cannot be found, it is most likely a leftover
|
// If the channel cannot be found, it is most likely a leftover
|
||||||
// message for a channel that was closed, so we can consider it
|
// message for a channel that was closed, so we can consider it
|
||||||
// stale.
|
// stale.
|
||||||
if err == channeldb.ErrEdgeNotFound {
|
if errors.Is(err, channeldb.ErrEdgeNotFound) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -2139,7 +2139,7 @@ func (d *AuthenticatedGossiper) isMsgStale(msg lnwire.Message) bool {
|
|||||||
// If the channel cannot be found, it is most likely a leftover
|
// If the channel cannot be found, it is most likely a leftover
|
||||||
// message for a channel that was closed, so we can consider it
|
// message for a channel that was closed, so we can consider it
|
||||||
// stale.
|
// stale.
|
||||||
if err == channeldb.ErrEdgeNotFound {
|
if errors.Is(err, channeldb.ErrEdgeNotFound) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -2750,12 +2750,12 @@ func (d *AuthenticatedGossiper) handleChanUpdate(nMsg *networkMsg,
|
|||||||
defer d.channelMtx.Unlock(graphScid.ToUint64())
|
defer d.channelMtx.Unlock(graphScid.ToUint64())
|
||||||
|
|
||||||
chanInfo, e1, e2, err := d.cfg.Router.GetChannelByID(graphScid)
|
chanInfo, e1, e2, err := d.cfg.Router.GetChannelByID(graphScid)
|
||||||
switch err {
|
switch {
|
||||||
// No error, break.
|
// No error, break.
|
||||||
case nil:
|
case err == nil:
|
||||||
break
|
break
|
||||||
|
|
||||||
case channeldb.ErrZombieEdge:
|
case errors.Is(err, channeldb.ErrZombieEdge):
|
||||||
err = d.processZombieUpdate(chanInfo, graphScid, upd)
|
err = d.processZombieUpdate(chanInfo, graphScid, upd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Debug(err)
|
log.Debug(err)
|
||||||
@@ -2768,11 +2768,11 @@ func (d *AuthenticatedGossiper) handleChanUpdate(nMsg *networkMsg,
|
|||||||
// needed to ensure the edge exists in the graph before
|
// needed to ensure the edge exists in the graph before
|
||||||
// applying the update.
|
// applying the update.
|
||||||
fallthrough
|
fallthrough
|
||||||
case channeldb.ErrGraphNotFound:
|
case errors.Is(err, channeldb.ErrGraphNotFound):
|
||||||
fallthrough
|
fallthrough
|
||||||
case channeldb.ErrGraphNoEdgesFound:
|
case errors.Is(err, channeldb.ErrGraphNoEdgesFound):
|
||||||
fallthrough
|
fallthrough
|
||||||
case channeldb.ErrEdgeNotFound:
|
case errors.Is(err, channeldb.ErrEdgeNotFound):
|
||||||
// If the edge corresponding to this ChannelUpdate was not
|
// If the edge corresponding to this ChannelUpdate was not
|
||||||
// found in the graph, this might be a channel in the process
|
// found in the graph, this might be a channel in the process
|
||||||
// of being opened, and we haven't processed our own
|
// of being opened, and we haven't processed our own
|
||||||
|
|||||||
@@ -195,7 +195,7 @@ func (m *ChanStatusManager) start() error {
|
|||||||
// have been pruned from the channel graph but not yet from our
|
// have been pruned from the channel graph but not yet from our
|
||||||
// set of channels. We'll skip it as we can't determine its
|
// set of channels. We'll skip it as we can't determine its
|
||||||
// initial state.
|
// initial state.
|
||||||
case err == channeldb.ErrEdgeNotFound:
|
case errors.Is(err, channeldb.ErrEdgeNotFound):
|
||||||
log.Warnf("Unable to find channel policies for %v, "+
|
log.Warnf("Unable to find channel policies for %v, "+
|
||||||
"skipping. This is typical if the channel is "+
|
"skipping. This is typical if the channel is "+
|
||||||
"in the process of closing.", c.FundingOutpoint)
|
"in the process of closing.", c.FundingOutpoint)
|
||||||
@@ -580,7 +580,7 @@ func (m *ChanStatusManager) disableInactiveChannels() {
|
|||||||
// that the channel has been closed. Thus we remove the
|
// that the channel has been closed. Thus we remove the
|
||||||
// outpoint from the set of tracked outpoints to prevent
|
// outpoint from the set of tracked outpoints to prevent
|
||||||
// further attempts.
|
// further attempts.
|
||||||
if err == channeldb.ErrEdgeNotFound {
|
if errors.Is(err, channeldb.ErrEdgeNotFound) {
|
||||||
log.Debugf("Removing channel(%v) from "+
|
log.Debugf("Removing channel(%v) from "+
|
||||||
"consideration for passive disabling",
|
"consideration for passive disabling",
|
||||||
outpoint)
|
outpoint)
|
||||||
|
|||||||
+1
-1
@@ -974,7 +974,7 @@ func (p *Brontide) loadActiveChannels(chans []*channeldb.OpenChannel) (
|
|||||||
info, p1, p2, err := graph.FetchChannelEdgesByOutpoint(
|
info, p1, p2, err := graph.FetchChannelEdgesByOutpoint(
|
||||||
&chanPoint,
|
&chanPoint,
|
||||||
)
|
)
|
||||||
if err != nil && err != channeldb.ErrEdgeNotFound {
|
if err != nil && !errors.Is(err, channeldb.ErrEdgeNotFound) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -2891,7 +2891,7 @@ func abandonChanFromGraph(chanGraph *channeldb.ChannelGraph,
|
|||||||
// the graph, so we'll return a nil error.
|
// the graph, so we'll return a nil error.
|
||||||
chanID, err := chanGraph.ChannelID(chanPoint)
|
chanID, err := chanGraph.ChannelID(chanPoint)
|
||||||
switch {
|
switch {
|
||||||
case err == channeldb.ErrEdgeNotFound:
|
case errors.Is(err, channeldb.ErrEdgeNotFound):
|
||||||
return nil
|
return nil
|
||||||
case err != nil:
|
case err != nil:
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -1266,7 +1266,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
|
|||||||
info, e1, e2, err := s.graphDB.FetchChannelEdgesByID(
|
info, e1, e2, err := s.graphDB.FetchChannelEdgesByID(
|
||||||
scid.ToUint64(),
|
scid.ToUint64(),
|
||||||
)
|
)
|
||||||
if err == channeldb.ErrEdgeNotFound {
|
if errors.Is(err, channeldb.ErrEdgeNotFound) {
|
||||||
// This is unlikely but there is a slim chance of this
|
// This is unlikely but there is a slim chance of this
|
||||||
// being hit if lnd was killed via SIGKILL and the
|
// being hit if lnd was killed via SIGKILL and the
|
||||||
// funding manager was stepping through the delete
|
// funding manager was stepping through the delete
|
||||||
|
|||||||
Reference in new issue
Block a user