Skip to content

Commit 870c865

Browse files
committed
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.
1 parent 4dbbd83 commit 870c865

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

discovery/gossiper_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,12 @@ func (r *mockGraphSource) AddNode(node *models.LightningNode,
107107
return nil
108108
}
109109

110+
func (r *mockGraphSource) MarkZombieEdge(scid uint64) error {
111+
return r.MarkEdgeZombie(
112+
lnwire.NewShortChanIDFromInt(scid), [33]byte{}, [33]byte{},
113+
)
114+
}
115+
110116
func (r *mockGraphSource) AddEdge(info *models.ChannelEdgeInfo,
111117
_ ...batch.SchedulerOption) error {
112118

graph/builder.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,9 +1008,9 @@ func (b *Builder) assertNodeAnnFreshness(node route.Vertex,
10081008
return nil
10091009
}
10101010

1011-
// addZombieEdge adds a channel that failed complete validation into the zombie
1011+
// MarkZombieEdge adds a channel that failed complete validation into the zombie
10121012
// index so we can avoid having to re-validate it in the future.
1013-
func (b *Builder) addZombieEdge(chanID uint64) error {
1013+
func (b *Builder) MarkZombieEdge(chanID uint64) error {
10141014
// If the edge fails validation we'll mark the edge itself as a zombie
10151015
// so we don't continue to request it. We use the "zero key" for both
10161016
// node pubkeys so this edge can't be resurrected.
@@ -1306,7 +1306,7 @@ func (b *Builder) addEdge(edge *models.ChannelEdgeInfo,
13061306
// we'll mark the edge itself as a zombie so we don't
13071307
// continue to request it. We use the "zero key" for
13081308
// both node pubkeys so this edge can't be resurrected.
1309-
zErr := b.addZombieEdge(edge.ChannelID)
1309+
zErr := b.MarkZombieEdge(edge.ChannelID)
13101310
if zErr != nil {
13111311
return zErr
13121312
}
@@ -1343,7 +1343,7 @@ func (b *Builder) addEdge(edge *models.ChannelEdgeInfo,
13431343
if err != nil {
13441344
// Mark the edge as a zombie so we won't try to re-validate it
13451345
// on start up.
1346-
if err := b.addZombieEdge(edge.ChannelID); err != nil {
1346+
if err := b.MarkZombieEdge(edge.ChannelID); err != nil {
13471347
return err
13481348
}
13491349

@@ -1358,7 +1358,7 @@ func (b *Builder) addEdge(edge *models.ChannelEdgeInfo,
13581358
)
13591359
if err != nil {
13601360
if errors.Is(err, btcwallet.ErrOutputSpent) {
1361-
zErr := b.addZombieEdge(edge.ChannelID)
1361+
zErr := b.MarkZombieEdge(edge.ChannelID)
13621362
if zErr != nil {
13631363
return zErr
13641364
}

graph/interfaces.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ type ChannelGraphSource interface {
8585
// public key. channeldb.ErrGraphNodeNotFound is returned if the node
8686
// doesn't exist within the graph.
8787
FetchLightningNode(route.Vertex) (*models.LightningNode, error)
88+
89+
// MarkZombieEdge marks the channel with the given ID as a zombie edge.
90+
MarkZombieEdge(chanID uint64) error
8891
}
8992

9093
// DB is an interface describing a persisted Lightning Network graph.

0 commit comments

Comments
 (0)