mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-06-30 10:35:32 +02:00
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.
This commit is contained in:
@ -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 {
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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.
|
||||
|
Reference in New Issue
Block a user