graph/db: thread context through MarkEdgeZombie

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

No files matched your search

+3 -1
View File
@@ -913,7 +913,9 @@ func (b *Builder) MarkZombieEdge(chanID uint64) error {
// so we don't continue to request it. We use the "zero key" for both
// node pubkeys so this edge can't be resurrected.
var zeroKey [33]byte
err := b.cfg.Graph.MarkEdgeZombie(chanID, zeroKey, zeroKey)
err := b.cfg.Graph.MarkEdgeZombie(
context.TODO(), chanID, zeroKey, zeroKey,
)
if err != nil {
return fmt.Errorf("unable to mark spent chan(id=%v) as a "+
"zombie: %w", chanID, err)
+2 -2
View File
@@ -564,10 +564,10 @@ func (c *ChannelGraph) FilterKnownChanIDs(chansInfo []ChannelUpdateInfo,
// MarkEdgeZombie attempts to mark a channel identified by its channel ID as a
// zombie. This method is used on an ad-hoc basis, when channels need to be
// marked as zombies outside the normal pruning cycle.
func (c *ChannelGraph) MarkEdgeZombie(chanID uint64,
func (c *ChannelGraph) MarkEdgeZombie(ctx context.Context, chanID uint64,
pubKey1, pubKey2 [33]byte) error {
err := c.db.MarkEdgeZombie(chanID, pubKey1, pubKey2)
err := c.db.MarkEdgeZombie(ctx, chanID, pubKey1, pubKey2)
if err != nil {
return err
}
+9 -4
View File
@@ -2929,6 +2929,7 @@ func TestChanUpdatesInHorizonBoundaryConditions(t *testing.T) {
// FilterKnownChanIDs is tested in TestFilterKnownChanIDs.
func TestFilterKnownChanIDsZombieRevival(t *testing.T) {
t.Parallel()
ctx := t.Context()
graph := MakeTestGraph(t)
@@ -2946,9 +2947,13 @@ func TestFilterKnownChanIDsZombieRevival(t *testing.T) {
}
// Mark channel 1 and 2 as zombies.
err := graph.MarkEdgeZombie(scid1.ToUint64(), [33]byte{}, [33]byte{})
err := graph.MarkEdgeZombie(
ctx, scid1.ToUint64(), [33]byte{}, [33]byte{},
)
require.NoError(t, err)
err = graph.MarkEdgeZombie(scid2.ToUint64(), [33]byte{}, [33]byte{})
err = graph.MarkEdgeZombie(
ctx, scid2.ToUint64(), [33]byte{}, [33]byte{},
)
require.NoError(t, err)
require.True(t, isZombie(scid1))
@@ -3299,7 +3304,7 @@ func TestStressTestChannelGraphAPI(t *testing.T) {
}
return graph.MarkEdgeZombie(
channel.id.ToUint64(),
ctx, channel.id.ToUint64(),
node1.PubKeyBytes,
node2.PubKeyBytes,
)
@@ -4592,7 +4597,7 @@ func TestGraphZombieIndex(t *testing.T) {
// If we mark the edge as a zombie manually, then it should show up as
// being a zombie once again.
err = graph.MarkEdgeZombie(
edge.ChannelID, node1.PubKeyBytes, node2.PubKeyBytes,
ctx, edge.ChannelID, node1.PubKeyBytes, node2.PubKeyBytes,
)
require.NoError(t, err, "unable to mark edge as zombie")
+1 -1
View File
@@ -324,7 +324,7 @@ type Store interface { //nolint:interfacebloat
// MarkEdgeZombie attempts to mark a channel identified by its channel
// ID as a zombie. This method is used on an ad-hoc basis, when channels
// need to be marked as zombies outside the normal pruning cycle.
MarkEdgeZombie(chanID uint64,
MarkEdgeZombie(ctx context.Context, chanID uint64,
pubKey1, pubKey2 [33]byte) error
// MarkEdgeLive clears an edge from our zombie index, deeming it as
+1 -1
View File
@@ -4243,7 +4243,7 @@ func (c *KVStore) ChannelView() ([]EdgePoint, error) {
// MarkEdgeZombie attempts to mark a channel identified by its channel ID as a
// zombie. This method is used on an ad-hoc basis, when channels need to be
// marked as zombies outside the normal pruning cycle.
func (c *KVStore) MarkEdgeZombie(chanID uint64,
func (c *KVStore) MarkEdgeZombie(_ context.Context, chanID uint64,
pubKey1, pubKey2 [33]byte) error {
c.cacheMu.Lock()
+1 -3
View File
@@ -1783,11 +1783,9 @@ func (s *SQLStore) FilterChannelRange(ctx context.Context, startHeight,
// marked as zombies outside the normal pruning cycle.
//
// NOTE: part of the Store interface.
func (s *SQLStore) MarkEdgeZombie(chanID uint64,
func (s *SQLStore) MarkEdgeZombie(ctx context.Context, chanID uint64,
pubKey1, pubKey2 [33]byte) error {
ctx := context.TODO()
s.cacheMu.Lock()
defer s.cacheMu.Unlock()