Skip to content

Commit 00f5fd9

Browse files
committed
graph: add IsZombieEdge method
This is in preparation for the commit where we move across all the funding tx validation so that we can test that we are correctly updating the zombie index.
1 parent 870c865 commit 00f5fd9

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

discovery/gossiper_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,17 @@ func (r *mockGraphSource) MarkZombieEdge(scid uint64) error {
113113
)
114114
}
115115

116+
func (r *mockGraphSource) IsZombieEdge(chanID lnwire.ShortChannelID) (bool,
117+
error) {
118+
119+
r.mu.Lock()
120+
defer r.mu.Unlock()
121+
122+
_, ok := r.zombies[chanID.ToUint64()]
123+
124+
return ok, nil
125+
}
126+
116127
func (r *mockGraphSource) AddEdge(info *models.ChannelEdgeInfo,
117128
_ ...batch.SchedulerOption) error {
118129

graph/builder.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1630,6 +1630,16 @@ func (b *Builder) IsKnownEdge(chanID lnwire.ShortChannelID) bool {
16301630
return exists || isZombie
16311631
}
16321632

1633+
// IsZombieEdge returns true if the graph source has marked the given channel ID
1634+
// as a zombie edge.
1635+
//
1636+
// NOTE: This method is part of the ChannelGraphSource interface.
1637+
func (b *Builder) IsZombieEdge(chanID lnwire.ShortChannelID) (bool, error) {
1638+
_, _, _, isZombie, err := b.cfg.Graph.HasChannelEdge(chanID.ToUint64())
1639+
1640+
return isZombie, err
1641+
}
1642+
16331643
// IsStaleEdgePolicy returns true if the graph source has a channel edge for
16341644
// the passed channel ID (and flags) that have a more recent timestamp.
16351645
//

graph/interfaces.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ type ChannelGraphSource interface {
8888

8989
// MarkZombieEdge marks the channel with the given ID as a zombie edge.
9090
MarkZombieEdge(chanID uint64) error
91+
92+
// IsZombieEdge returns true if the edge with the given channel ID is
93+
// currently marked as a zombie edge.
94+
IsZombieEdge(chanID lnwire.ShortChannelID) (bool, error)
9195
}
9296

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

0 commit comments

Comments
 (0)