graph/db: thread context through MarkEdgeLive

This commit is contained in:
Elle Mouton committed 2026-02-25 15:33:34 +02:00
1 parent c270367071
commit 8a96e5f3d2
6 files changed
+12 -10

No files matched your search

+3 -1
View File
@@ -1417,5 +1417,7 @@ func (b *Builder) IsStaleEdgePolicy(chanID lnwire.ShortChannelID,
//
// NOTE: This method is part of the ChannelGraphSource interface.
func (b *Builder) MarkEdgeLive(chanID lnwire.ShortChannelID) error {
return b.cfg.Graph.MarkEdgeLive(chanID.ToUint64())
return b.cfg.Graph.MarkEdgeLive(
context.TODO(), chanID.ToUint64(),
)
}
+3 -3
View File
@@ -343,8 +343,8 @@ func (c *ChannelGraph) AddChannelEdge(ctx context.Context,
// MarkEdgeLive clears an edge from our zombie index, deeming it as live.
// If the cache is enabled, the edge will be added back to the graph cache if
// we still have a record of this channel in the DB.
func (c *ChannelGraph) MarkEdgeLive(chanID uint64) error {
err := c.db.MarkEdgeLive(chanID)
func (c *ChannelGraph) MarkEdgeLive(ctx context.Context, chanID uint64) error {
err := c.db.MarkEdgeLive(ctx, chanID)
if err != nil {
return err
}
@@ -547,7 +547,7 @@ func (c *ChannelGraph) FilterKnownChanIDs(chansInfo []ChannelUpdateInfo,
// alive, and we let it be added to the set of IDs to query our
// peer for.
err := c.db.MarkEdgeLive(
info.ShortChannelID.ToUint64(),
context.TODO(), info.ShortChannelID.ToUint64(),
)
// Since there is a chance that the edge could have been marked
// as "live" between the FilterKnownChanIDs call and the
+3 -2
View File
@@ -4580,12 +4580,13 @@ func TestGraphZombieIndex(t *testing.T) {
// Similarly, if we mark the same edge as live, we should no longer see
// it within the index.
require.NoError(t, graph.MarkEdgeLive(edge.ChannelID))
require.NoError(t, graph.MarkEdgeLive(ctx, edge.ChannelID))
// Attempting to mark the edge as live again now that it is no longer
// in the zombie index should fail.
require.ErrorIs(
t, graph.MarkEdgeLive(edge.ChannelID), ErrZombieEdgeNotFound,
t, graph.MarkEdgeLive(ctx, edge.ChannelID),
ErrZombieEdgeNotFound,
)
isZombie, _, _, err = graph.IsZombieEdge(edge.ChannelID)
+1 -1
View File
@@ -329,7 +329,7 @@ type Store interface { //nolint:interfacebloat
// MarkEdgeLive clears an edge from our zombie index, deeming it as
// live.
MarkEdgeLive(chanID uint64) error
MarkEdgeLive(ctx context.Context, chanID uint64) error
// IsZombieEdge returns whether the edge is considered zombie. If it is
// a zombie, then the two node public keys corresponding to this edge
+1 -1
View File
@@ -4289,7 +4289,7 @@ func markEdgeZombie(zombieIndex kvdb.RwBucket, chanID uint64, pubKey1,
}
// MarkEdgeLive clears an edge from our zombie index, deeming it as live.
func (c *KVStore) MarkEdgeLive(chanID uint64) error {
func (c *KVStore) MarkEdgeLive(_ context.Context, chanID uint64) error {
c.cacheMu.Lock()
defer c.cacheMu.Unlock()
+1 -2
View File
@@ -1815,12 +1815,11 @@ func (s *SQLStore) MarkEdgeZombie(ctx context.Context, chanID uint64,
// MarkEdgeLive clears an edge from our zombie index, deeming it as live.
//
// NOTE: part of the Store interface.
func (s *SQLStore) MarkEdgeLive(chanID uint64) error {
func (s *SQLStore) MarkEdgeLive(ctx context.Context, chanID uint64) error {
s.cacheMu.Lock()
defer s.cacheMu.Unlock()
var (
ctx = context.TODO()
chanIDB = channelIDToBytes(chanID)
)