graphdb: pass context to HasChannelEdge

This commit is contained in:
Elle Mouton committed 2026-02-25 16:11:29 +02:00
1 parent 87ed09a829
commit 3079c07afb
7 files changed
+32 -34

No files matched your search

+7 -5
View File
@@ -681,10 +681,10 @@ func (c *ChannelGraph) HasV1ChannelEdge(ctx context.Context,
}
// HasChannelEdge returns true if the database knows of a channel edge.
func (c *ChannelGraph) HasChannelEdge(v lnwire.GossipVersion,
chanID uint64) (bool, bool, error) {
func (c *ChannelGraph) HasChannelEdge(ctx context.Context,
v lnwire.GossipVersion, chanID uint64) (bool, bool, error) {
return c.db.HasChannelEdge(v, chanID)
return c.db.HasChannelEdge(ctx, v, chanID)
}
// AddEdgeProof sets the proof of an existing edge in the graph database.
@@ -919,8 +919,10 @@ func (c *VersionedGraph) DeleteChannelEdges(ctx context.Context,
// passed channel ID and this graph's gossip version, and false otherwise. If it
// is not found, then the zombie index is checked and its result is returned as
// the second boolean.
func (c *VersionedGraph) HasChannelEdge(chanID uint64) (bool, bool, error) {
return c.db.HasChannelEdge(c.v, chanID)
func (c *VersionedGraph) HasChannelEdge(ctx context.Context,
chanID uint64) (bool, bool, error) {
return c.db.HasChannelEdge(ctx, c.v, chanID)
}
// ForEachSourceNodeChannel iterates through all channels of the source node.
+5 -5
View File
@@ -918,13 +918,13 @@ func TestDisconnectBlockAtHeight(t *testing.T) {
// The two first edges should be removed from the db.
has, isZombie, err := graph.HasChannelEdge(
lnwire.GossipVersion1, edgeInfo.ChannelID,
ctx, lnwire.GossipVersion1, edgeInfo.ChannelID,
)
require.NoError(t, err, "unable to query for edge")
require.False(t, has)
require.False(t, isZombie)
has, isZombie, err = graph.HasChannelEdge(
lnwire.GossipVersion1, edgeInfo2.ChannelID,
ctx, lnwire.GossipVersion1, edgeInfo2.ChannelID,
)
require.NoError(t, err, "unable to query for edge")
require.False(t, has)
@@ -932,7 +932,7 @@ func TestDisconnectBlockAtHeight(t *testing.T) {
// Edge 3 should not be removed.
has, isZombie, err = graph.HasChannelEdge(
lnwire.GossipVersion1, edgeInfo3.ChannelID,
ctx, lnwire.GossipVersion1, edgeInfo3.ChannelID,
)
require.NoError(t, err, "unable to query for edge")
require.True(t, has)
@@ -1184,7 +1184,7 @@ func testEdgeInfoUpdates(t *testing.T, v lnwire.GossipVersion) {
// Check for existence of the edge within the database, it should be
// found.
found, isZombie, err := graph.HasChannelEdge(chanID)
found, isZombie, err := graph.HasChannelEdge(ctx, chanID)
require.NoError(t, err, "unable to query for edge")
require.True(t, found)
require.False(t, isZombie)
@@ -3360,7 +3360,7 @@ func TestStressTestChannelGraphAPI(t *testing.T) {
}
_, _, err := graph.HasChannelEdge(
lnwire.GossipVersion1,
ctx, lnwire.GossipVersion1,
channel.id.ToUint64(),
)
+2 -2
View File
@@ -218,8 +218,8 @@ type Store interface { //nolint:interfacebloat
// with the passed channel ID and gossip version, and false otherwise.
// If it is not found, then the zombie index is checked and its result
// is returned as the second boolean.
HasChannelEdge(v lnwire.GossipVersion, chanID uint64) (bool, bool,
error)
HasChannelEdge(ctx context.Context, v lnwire.GossipVersion,
chanID uint64) (bool, bool, error)
// DeleteChannelEdges removes edges with the given channel IDs from the
// database and marks them as zombies. This ensures that we're unable to
+2 -4
View File
@@ -1427,16 +1427,14 @@ func (c *KVStore) HasV1ChannelEdge(_ context.Context,
// passed channel ID and gossip version, and false otherwise. If it is not
// found, then the zombie index is checked and its result is returned as the
// second boolean.
func (c *KVStore) HasChannelEdge(v lnwire.GossipVersion,
func (c *KVStore) HasChannelEdge(ctx context.Context, v lnwire.GossipVersion,
chanID uint64) (bool, bool, error) {
if v != lnwire.GossipVersion1 {
return false, false, ErrVersionNotSupportedForKVDB
}
_, _, exists, isZombie, err := c.HasV1ChannelEdge(
context.TODO(), chanID,
)
_, _, exists, isZombie, err := c.HasV1ChannelEdge(ctx, chanID)
return exists, isZombie, err
}
+2 -4
View File
@@ -2361,8 +2361,8 @@ func (s *SQLStore) HasV1ChannelEdge(ctx context.Context,
// result is returned as the second boolean.
//
// NOTE: part of the Store interface.
func (s *SQLStore) HasChannelEdge(v lnwire.GossipVersion,
chanID uint64) (bool, bool, error) {
func (s *SQLStore) HasChannelEdge(ctx context.Context,
v lnwire.GossipVersion, chanID uint64) (bool, bool, error) {
if !isKnownGossipVersion(v) {
return false, false, fmt.Errorf(
@@ -2370,8 +2370,6 @@ func (s *SQLStore) HasChannelEdge(v lnwire.GossipVersion,
)
}
ctx := context.TODO()
var (
exists bool
isZombie bool