graph/db: add versioned HasChannelEdge method

Add a new HasChannelEdge method that takes a gossip version parameter
and returns only existence and zombie status, without timestamp data.
This supports both v1 and v2 gossip protocols.

The original HasChannelEdge method is renamed to HasV1ChannelEdge to
preserve v1-specific functionality for callers that need timestamp
information. All call sites are updated accordingly.

The SQL store implementation now handles both gossip versions, using
timestamps for v1 and block heights for v2 policies, with proper
reject cache support for both versions.
This commit is contained in:
Elle Mouton committed 2026-02-13 07:21:24 +02:00
1 parent 4a6213c35e
commit 506ec037e2
8 files changed
+258 -54

No files matched your search

+14 -5
View File
@@ -886,7 +886,9 @@ func TestDisconnectBlockAtHeight(t *testing.T) {
}
// The two first edges should be removed from the db.
_, _, has, isZombie, err := graph.HasChannelEdge(edgeInfo.ChannelID)
has, isZombie, err := graph.HasChannelEdge(
lnwire.GossipVersion1, edgeInfo.ChannelID,
)
require.NoError(t, err, "unable to query for edge")
if has {
t.Fatalf("edge1 was not pruned from the graph")
@@ -894,7 +896,9 @@ func TestDisconnectBlockAtHeight(t *testing.T) {
if isZombie {
t.Fatal("reorged edge1 should not be marked as zombie")
}
_, _, has, isZombie, err = graph.HasChannelEdge(edgeInfo2.ChannelID)
has, isZombie, err = graph.HasChannelEdge(
lnwire.GossipVersion1, edgeInfo2.ChannelID,
)
require.NoError(t, err, "unable to query for edge")
if has {
t.Fatalf("edge2 was not pruned from the graph")
@@ -904,7 +908,9 @@ func TestDisconnectBlockAtHeight(t *testing.T) {
}
// Edge 3 should not be removed.
_, _, has, isZombie, err = graph.HasChannelEdge(edgeInfo3.ChannelID)
has, isZombie, err = graph.HasChannelEdge(
lnwire.GossipVersion1, edgeInfo3.ChannelID,
)
require.NoError(t, err, "unable to query for edge")
if !has {
t.Fatalf("edge3 was pruned from the graph")
@@ -1129,7 +1135,9 @@ func TestEdgeInfoUpdates(t *testing.T) {
// Check for existence of the edge within the database, it should be
// found.
_, _, found, isZombie, err := graph.HasChannelEdge(chanID)
found, isZombie, err := graph.HasChannelEdge(
lnwire.GossipVersion1, chanID,
)
require.NoError(t, err, "unable to query for edge")
if !found {
t.Fatalf("graph should have of inserted edge")
@@ -3317,7 +3325,8 @@ func TestStressTestChannelGraphAPI(t *testing.T) {
return nil
}
_, _, _, _, err := graph.HasChannelEdge(
_, _, err := graph.HasChannelEdge(
lnwire.GossipVersion1,
channel.id.ToUint64(),
)