From 870c8657637aabb8d65aa0d082659d72e7a898cb Mon Sep 17 00:00:00 2001 From: Elle Mouton Date: Wed, 5 Feb 2025 10:51:53 +0200 Subject: [PATCH] graph: export addZombieEdge and rename to MarkZombieEdge The `graph.Builder`'s `addZombieEdge` method is currently called during funding transaction validation for the case where the funding tx is not found. In preparation for moving this code to the gossiper, we export the method and add it to the ChannelGraphSource interface so that the gossiper will be able to call it later on. --- discovery/gossiper_test.go | 6 ++++++ graph/builder.go | 10 +++++----- graph/interfaces.go | 3 +++ 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/discovery/gossiper_test.go b/discovery/gossiper_test.go index afd07047a..94d7d426e 100644 --- a/discovery/gossiper_test.go +++ b/discovery/gossiper_test.go @@ -107,6 +107,12 @@ func (r *mockGraphSource) AddNode(node *models.LightningNode, return nil } +func (r *mockGraphSource) MarkZombieEdge(scid uint64) error { + return r.MarkEdgeZombie( + lnwire.NewShortChanIDFromInt(scid), [33]byte{}, [33]byte{}, + ) +} + func (r *mockGraphSource) AddEdge(info *models.ChannelEdgeInfo, _ ...batch.SchedulerOption) error { diff --git a/graph/builder.go b/graph/builder.go index db73c9272..8f1d4bbc0 100644 --- a/graph/builder.go +++ b/graph/builder.go @@ -1008,9 +1008,9 @@ func (b *Builder) assertNodeAnnFreshness(node route.Vertex, return nil } -// addZombieEdge adds a channel that failed complete validation into the zombie +// MarkZombieEdge adds a channel that failed complete validation into the zombie // index so we can avoid having to re-validate it in the future. -func (b *Builder) addZombieEdge(chanID uint64) error { +func (b *Builder) MarkZombieEdge(chanID uint64) error { // If the edge fails validation we'll mark the edge itself as a zombie // so we don't continue to request it. We use the "zero key" for both // node pubkeys so this edge can't be resurrected. @@ -1306,7 +1306,7 @@ func (b *Builder) addEdge(edge *models.ChannelEdgeInfo, // we'll mark the edge itself as a zombie so we don't // continue to request it. We use the "zero key" for // both node pubkeys so this edge can't be resurrected. - zErr := b.addZombieEdge(edge.ChannelID) + zErr := b.MarkZombieEdge(edge.ChannelID) if zErr != nil { return zErr } @@ -1343,7 +1343,7 @@ func (b *Builder) addEdge(edge *models.ChannelEdgeInfo, if err != nil { // Mark the edge as a zombie so we won't try to re-validate it // on start up. - if err := b.addZombieEdge(edge.ChannelID); err != nil { + if err := b.MarkZombieEdge(edge.ChannelID); err != nil { return err } @@ -1358,7 +1358,7 @@ func (b *Builder) addEdge(edge *models.ChannelEdgeInfo, ) if err != nil { if errors.Is(err, btcwallet.ErrOutputSpent) { - zErr := b.addZombieEdge(edge.ChannelID) + zErr := b.MarkZombieEdge(edge.ChannelID) if zErr != nil { return zErr } diff --git a/graph/interfaces.go b/graph/interfaces.go index 10ca200f3..afa0ef687 100644 --- a/graph/interfaces.go +++ b/graph/interfaces.go @@ -85,6 +85,9 @@ type ChannelGraphSource interface { // public key. channeldb.ErrGraphNodeNotFound is returned if the node // doesn't exist within the graph. FetchLightningNode(route.Vertex) (*models.LightningNode, error) + + // MarkZombieEdge marks the channel with the given ID as a zombie edge. + MarkZombieEdge(chanID uint64) error } // DB is an interface describing a persisted Lightning Network graph.