graph/db: thread context through FetchChannelEdgesByOutpoint

This commit is contained in:
Elle Mouton committed 2026-02-25 16:11:29 +02:00
1 parent 6bbb9a32fc
commit 1d4c6aadb4
10 files changed
+33 -19

No files matched your search

+6 -4
View File
@@ -729,12 +729,13 @@ func (c *ChannelGraph) FetchChanInfos(v lnwire.GossipVersion,
// FetchChannelEdgesByOutpoint attempts to lookup directed edges by funding
// outpoint.
func (c *ChannelGraph) FetchChannelEdgesByOutpoint(op *wire.OutPoint) (
func (c *ChannelGraph) FetchChannelEdgesByOutpoint(ctx context.Context,
op *wire.OutPoint) (
*models.ChannelEdgeInfo, *models.ChannelEdgePolicy,
*models.ChannelEdgePolicy, error) {
return c.db.FetchChannelEdgesByOutpoint(
lnwire.GossipVersion1, op,
ctx, lnwire.GossipVersion1, op,
)
}
@@ -823,11 +824,12 @@ func (c *VersionedGraph) FetchChannelEdgesByID(ctx context.Context,
// FetchChannelEdgesByOutpoint attempts to lookup directed edges by funding
// outpoint.
func (c *VersionedGraph) FetchChannelEdgesByOutpoint(op *wire.OutPoint) (
func (c *VersionedGraph) FetchChannelEdgesByOutpoint(ctx context.Context,
op *wire.OutPoint) (
*models.ChannelEdgeInfo, *models.ChannelEdgePolicy,
*models.ChannelEdgePolicy, error) {
return c.db.FetchChannelEdgesByOutpoint(c.v, op)
return c.db.FetchChannelEdgesByOutpoint(ctx, c.v, op)
}
// IsZombieEdge returns whether the edge is considered zombie for this version.
+5 -3
View File
@@ -693,7 +693,9 @@ func testEdgeInsertionDeletion(t *testing.T, v lnwire.GossipVersion) {
}
// Also verify fetching by outpoint returns the same data.
dbEdge2, _, _, err := graph.FetchChannelEdgesByOutpoint(&outpoint)
dbEdge2, _, _, err := graph.FetchChannelEdgesByOutpoint(
ctx, &outpoint,
)
require.NoError(t, err)
require.Equal(t, dbEdge.ChannelID, dbEdge2.ChannelID)
@@ -706,7 +708,7 @@ func testEdgeInsertionDeletion(t *testing.T, v lnwire.GossipVersion) {
// Ensure that any query attempts to lookup the delete channel edge are
// properly deleted.
_, _, _, err = graph.FetchChannelEdgesByOutpoint(&outpoint)
_, _, _, err = graph.FetchChannelEdgesByOutpoint(ctx, &outpoint)
require.ErrorIs(t, err, ErrEdgeNotFound)
// Assert that if the edge is a zombie, then FetchChannelEdgesByID
@@ -1206,7 +1208,7 @@ func testEdgeInfoUpdates(t *testing.T, v lnwire.GossipVersion) {
// Next, attempt to query the channel edges according to the outpoint
// of the channel.
dbEdgeInfo, dbEdge1, dbEdge2, err = graph.FetchChannelEdgesByOutpoint(
&outpoint,
ctx, &outpoint,
)
require.NoError(t, err, "unable to fetch channel by ID")
compareEdgePolicies(t, dbEdge1, edge1)
+2 -1
View File
@@ -296,7 +296,8 @@ type Store interface { //nolint:interfacebloat
// houses the general information for the channel itself is returned as
// well as two structs that contain the routing policies for the channel
// in either direction.
FetchChannelEdgesByOutpoint(v lnwire.GossipVersion, op *wire.OutPoint) (
FetchChannelEdgesByOutpoint(ctx context.Context,
v lnwire.GossipVersion, op *wire.OutPoint) (
*models.ChannelEdgeInfo, *models.ChannelEdgePolicy,
*models.ChannelEdgePolicy, error)
+3 -2
View File
@@ -3899,8 +3899,9 @@ func computeEdgePolicyKeys(info *models.ChannelEdgeInfo) ([]byte, []byte) {
// found, then ErrEdgeNotFound is returned. A struct which houses the general
// information for the channel itself is returned as well as two structs that
// contain the routing policies for the channel in either direction.
func (c *KVStore) FetchChannelEdgesByOutpoint(v lnwire.GossipVersion,
op *wire.OutPoint) (*models.ChannelEdgeInfo, *models.ChannelEdgePolicy,
func (c *KVStore) FetchChannelEdgesByOutpoint(_ context.Context,
v lnwire.GossipVersion, op *wire.OutPoint) (
*models.ChannelEdgeInfo, *models.ChannelEdgePolicy,
*models.ChannelEdgePolicy, error) {
var (
+3 -3
View File
@@ -2167,12 +2167,12 @@ func (s *SQLStore) FetchChannelEdgesByID(ctx context.Context,
// contain the routing policies for the channel in either direction.
//
// NOTE: part of the Store interface.
func (s *SQLStore) FetchChannelEdgesByOutpoint(v lnwire.GossipVersion,
op *wire.OutPoint) (*models.ChannelEdgeInfo, *models.ChannelEdgePolicy,
func (s *SQLStore) FetchChannelEdgesByOutpoint(ctx context.Context,
v lnwire.GossipVersion, op *wire.OutPoint) (
*models.ChannelEdgeInfo, *models.ChannelEdgePolicy,
*models.ChannelEdgePolicy, error) {
var (
ctx = context.TODO()
edge *models.ChannelEdgeInfo
policy1, policy2 *models.ChannelEdgePolicy
)