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

+11 -11
View File
@@ -319,7 +319,7 @@ func TestWakeUpOnStaleBranch(t *testing.T) {
}
// Check that the fundingTxs are in the graph db.
_, _, has, isZombie, err := ctx.graph.HasChannelEdge(chanID1)
has, isZombie, err := ctx.graph.HasChannelEdge(chanID1)
if err != nil {
t.Fatalf("error looking for edge: %v", chanID1)
}
@@ -330,7 +330,7 @@ func TestWakeUpOnStaleBranch(t *testing.T) {
t.Fatal("edge was marked as zombie")
}
_, _, has, isZombie, err = ctx.graph.HasChannelEdge(chanID2)
has, isZombie, err = ctx.graph.HasChannelEdge(chanID2)
if err != nil {
t.Fatalf("error looking for edge: %v", chanID2)
}
@@ -387,7 +387,7 @@ func TestWakeUpOnStaleBranch(t *testing.T) {
// The channel with chanID2 should not be in the database anymore,
// since it is not confirmed on the longest chain. chanID1 should
// still be.
_, _, has, isZombie, err = ctx.graph.HasChannelEdge(chanID1)
has, isZombie, err = ctx.graph.HasChannelEdge(chanID1)
require.NoError(t, err)
if !has {
@@ -397,7 +397,7 @@ func TestWakeUpOnStaleBranch(t *testing.T) {
t.Fatal("edge was marked as zombie")
}
_, _, has, isZombie, err = ctx.graph.HasChannelEdge(chanID2)
has, isZombie, err = ctx.graph.HasChannelEdge(chanID2)
if err != nil {
t.Fatalf("error looking for edge: %v", chanID2)
}
@@ -527,7 +527,7 @@ func TestDisconnectedBlocks(t *testing.T) {
}
// Check that the fundingTxs are in the graph db.
_, _, has, isZombie, err := ctx.graph.HasChannelEdge(chanID1)
has, isZombie, err := ctx.graph.HasChannelEdge(chanID1)
if err != nil {
t.Fatalf("error looking for edge: %v", chanID1)
}
@@ -538,7 +538,7 @@ func TestDisconnectedBlocks(t *testing.T) {
t.Fatal("edge was marked as zombie")
}
_, _, has, isZombie, err = ctx.graph.HasChannelEdge(chanID2)
has, isZombie, err = ctx.graph.HasChannelEdge(chanID2)
if err != nil {
t.Fatalf("error looking for edge: %v", chanID2)
}
@@ -580,7 +580,7 @@ func TestDisconnectedBlocks(t *testing.T) {
// chanID2 should not be in the database anymore, since it is not
// confirmed on the longest chain. chanID1 should still be.
_, _, has, isZombie, err = ctx.graph.HasChannelEdge(chanID1)
has, isZombie, err = ctx.graph.HasChannelEdge(chanID1)
if err != nil {
t.Fatalf("error looking for edge: %v", chanID1)
}
@@ -591,7 +591,7 @@ func TestDisconnectedBlocks(t *testing.T) {
t.Fatal("edge was marked as zombie")
}
_, _, has, isZombie, err = ctx.graph.HasChannelEdge(chanID2)
has, isZombie, err = ctx.graph.HasChannelEdge(chanID2)
if err != nil {
t.Fatalf("error looking for edge: %v", chanID2)
}
@@ -665,7 +665,7 @@ func TestChansClosedOfflinePruneGraph(t *testing.T) {
}
// The router should now be aware of the channel we created above.
_, _, hasChan, isZombie, err := ctx.graph.HasChannelEdge(
hasChan, isZombie, err := ctx.graph.HasChannelEdge(
chanID1.ToUint64(),
)
if err != nil {
@@ -747,7 +747,7 @@ func TestChansClosedOfflinePruneGraph(t *testing.T) {
// At this point, the channel that was pruned should no longer be known
// by the router.
_, _, hasChan, isZombie, err = ctx.graph.HasChannelEdge(
hasChan, isZombie, err = ctx.graph.HasChannelEdge(
chanID1.ToUint64(),
)
if err != nil {
@@ -1719,7 +1719,7 @@ func assertChannelsPruned(t *testing.T, graph *graphdb.VersionedGraph,
for _, channel := range channels {
_, shouldPrune := pruned[channel.ChannelID]
_, _, exists, isZombie, err := graph.HasChannelEdge(
exists, isZombie, err := graph.HasChannelEdge(
channel.ChannelID,
)
if err != nil {