graph/db: thread context through MarkEdgeLive
This commit is contained in:
6 files changed
+12
-10
No files matched your search
+3
-1
@@ -1417,5 +1417,7 @@ func (b *Builder) IsStaleEdgePolicy(chanID lnwire.ShortChannelID,
|
|||||||
//
|
//
|
||||||
// NOTE: This method is part of the ChannelGraphSource interface.
|
// NOTE: This method is part of the ChannelGraphSource interface.
|
||||||
func (b *Builder) MarkEdgeLive(chanID lnwire.ShortChannelID) error {
|
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
@@ -343,8 +343,8 @@ func (c *ChannelGraph) AddChannelEdge(ctx context.Context,
|
|||||||
// MarkEdgeLive clears an edge from our zombie index, deeming it as live.
|
// 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
|
// 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.
|
// we still have a record of this channel in the DB.
|
||||||
func (c *ChannelGraph) MarkEdgeLive(chanID uint64) error {
|
func (c *ChannelGraph) MarkEdgeLive(ctx context.Context, chanID uint64) error {
|
||||||
err := c.db.MarkEdgeLive(chanID)
|
err := c.db.MarkEdgeLive(ctx, chanID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
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
|
// alive, and we let it be added to the set of IDs to query our
|
||||||
// peer for.
|
// peer for.
|
||||||
err := c.db.MarkEdgeLive(
|
err := c.db.MarkEdgeLive(
|
||||||
info.ShortChannelID.ToUint64(),
|
context.TODO(), info.ShortChannelID.ToUint64(),
|
||||||
)
|
)
|
||||||
// Since there is a chance that the edge could have been marked
|
// Since there is a chance that the edge could have been marked
|
||||||
// as "live" between the FilterKnownChanIDs call and the
|
// as "live" between the FilterKnownChanIDs call and the
|
||||||
|
|||||||
@@ -4580,12 +4580,13 @@ func TestGraphZombieIndex(t *testing.T) {
|
|||||||
|
|
||||||
// Similarly, if we mark the same edge as live, we should no longer see
|
// Similarly, if we mark the same edge as live, we should no longer see
|
||||||
// it within the index.
|
// 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
|
// Attempting to mark the edge as live again now that it is no longer
|
||||||
// in the zombie index should fail.
|
// in the zombie index should fail.
|
||||||
require.ErrorIs(
|
require.ErrorIs(
|
||||||
t, graph.MarkEdgeLive(edge.ChannelID), ErrZombieEdgeNotFound,
|
t, graph.MarkEdgeLive(ctx, edge.ChannelID),
|
||||||
|
ErrZombieEdgeNotFound,
|
||||||
)
|
)
|
||||||
|
|
||||||
isZombie, _, _, err = graph.IsZombieEdge(edge.ChannelID)
|
isZombie, _, _, err = graph.IsZombieEdge(edge.ChannelID)
|
||||||
|
|||||||
@@ -329,7 +329,7 @@ type Store interface { //nolint:interfacebloat
|
|||||||
|
|
||||||
// MarkEdgeLive clears an edge from our zombie index, deeming it as
|
// MarkEdgeLive clears an edge from our zombie index, deeming it as
|
||||||
// live.
|
// live.
|
||||||
MarkEdgeLive(chanID uint64) error
|
MarkEdgeLive(ctx context.Context, chanID uint64) error
|
||||||
|
|
||||||
// IsZombieEdge returns whether the edge is considered zombie. If it is
|
// IsZombieEdge returns whether the edge is considered zombie. If it is
|
||||||
// a zombie, then the two node public keys corresponding to this edge
|
// a zombie, then the two node public keys corresponding to this edge
|
||||||
|
|||||||
@@ -4289,7 +4289,7 @@ func markEdgeZombie(zombieIndex kvdb.RwBucket, chanID uint64, pubKey1,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// MarkEdgeLive clears an edge from our zombie index, deeming it as live.
|
// 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()
|
c.cacheMu.Lock()
|
||||||
defer c.cacheMu.Unlock()
|
defer c.cacheMu.Unlock()
|
||||||
|
|
||||||
|
|||||||
@@ -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.
|
// MarkEdgeLive clears an edge from our zombie index, deeming it as live.
|
||||||
//
|
//
|
||||||
// NOTE: part of the Store interface.
|
// 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()
|
s.cacheMu.Lock()
|
||||||
defer s.cacheMu.Unlock()
|
defer s.cacheMu.Unlock()
|
||||||
|
|
||||||
var (
|
var (
|
||||||
ctx = context.TODO()
|
|
||||||
chanIDB = channelIDToBytes(chanID)
|
chanIDB = channelIDToBytes(chanID)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user