multi: return error from MarkEdgeLive if not found
Let MarkEdgLive return a new ErrNotZombieEdge error if an entry with the given channel ID cannot be found. In processZombieUpdate, we then check for this error and log accordingly.
This commit is contained in:
4 files changed
+25
-1
No files matched your search
@@ -75,6 +75,10 @@ var (
|
|||||||
// but it is marked as a zombie within the zombie index.
|
// but it is marked as a zombie within the zombie index.
|
||||||
ErrZombieEdge = errors.New("edge marked as zombie")
|
ErrZombieEdge = errors.New("edge marked as zombie")
|
||||||
|
|
||||||
|
// ErrZombieEdgeNotFound is an error returned when we attempt to find an
|
||||||
|
// edge in the zombie index which is not there.
|
||||||
|
ErrZombieEdgeNotFound = errors.New("edge not found in zombie index")
|
||||||
|
|
||||||
// ErrEdgeAlreadyExist is returned when edge with specific
|
// ErrEdgeAlreadyExist is returned when edge with specific
|
||||||
// channel id can't be added because it already exist.
|
// channel id can't be added because it already exist.
|
||||||
ErrEdgeAlreadyExist = fmt.Errorf("edge already exist")
|
ErrEdgeAlreadyExist = fmt.Errorf("edge already exist")
|
||||||
|
|||||||
@@ -3512,6 +3512,11 @@ func (c *ChannelGraph) MarkEdgeLive(chanID uint64) error {
|
|||||||
|
|
||||||
var k [8]byte
|
var k [8]byte
|
||||||
byteOrder.PutUint64(k[:], chanID)
|
byteOrder.PutUint64(k[:], chanID)
|
||||||
|
|
||||||
|
if len(zombieIndex.Get(k[:])) == 0 {
|
||||||
|
return ErrZombieEdgeNotFound
|
||||||
|
}
|
||||||
|
|
||||||
return zombieIndex.Delete(k[:])
|
return zombieIndex.Delete(k[:])
|
||||||
}, func() {})
|
}, func() {})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -3089,6 +3089,12 @@ func TestGraphZombieIndex(t *testing.T) {
|
|||||||
// it within the index.
|
// it within the index.
|
||||||
require.NoError(t, graph.MarkEdgeLive(edge.ChannelID))
|
require.NoError(t, graph.MarkEdgeLive(edge.ChannelID))
|
||||||
|
|
||||||
|
// Attempting to mark the edge as live again now that it is no longer
|
||||||
|
// in the zombie index should fail.
|
||||||
|
require.ErrorIs(
|
||||||
|
t, graph.MarkEdgeLive(edge.ChannelID), ErrZombieEdgeNotFound,
|
||||||
|
)
|
||||||
|
|
||||||
isZombie, _, _ = graph.IsZombieEdge(edge.ChannelID)
|
isZombie, _, _ = graph.IsZombieEdge(edge.ChannelID)
|
||||||
require.False(t, isZombie)
|
require.False(t, isZombie)
|
||||||
|
|
||||||
|
|||||||
+10
-1
@@ -2057,10 +2057,19 @@ func (d *AuthenticatedGossiper) processZombieUpdate(
|
|||||||
// come through again.
|
// come through again.
|
||||||
baseScid := lnwire.NewShortChanIDFromInt(chanInfo.ChannelID)
|
baseScid := lnwire.NewShortChanIDFromInt(chanInfo.ChannelID)
|
||||||
err = d.cfg.Router.MarkEdgeLive(baseScid)
|
err = d.cfg.Router.MarkEdgeLive(baseScid)
|
||||||
if err != nil {
|
switch {
|
||||||
|
case errors.Is(err, channeldb.ErrZombieEdgeNotFound):
|
||||||
|
log.Errorf("edge with chan_id=%v was not found in the "+
|
||||||
|
"zombie index: %v", err)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
|
||||||
|
case err != nil:
|
||||||
return fmt.Errorf("unable to remove edge with "+
|
return fmt.Errorf("unable to remove edge with "+
|
||||||
"chan_id=%v from zombie index: %v",
|
"chan_id=%v from zombie index: %v",
|
||||||
msg.ShortChannelID, err)
|
msg.ShortChannelID, err)
|
||||||
|
|
||||||
|
default:
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Debugf("Removed edge with chan_id=%v from zombie "+
|
log.Debugf("Removed edge with chan_id=%v from zombie "+
|
||||||
|
|||||||
Reference in new issue
Block a user