graph/db: thread context through IsZombieEdge

This commit is contained in:
Elle Mouton committed 2026-02-25 15:33:34 +02:00
1 parent 8a96e5f3d2
commit f98905ae99
5 files changed
+20 -17

No files matched your search

+6 -6
View File
@@ -754,10 +754,10 @@ func (c *ChannelGraph) ChannelView() ([]EdgePoint, error) {
}
// IsZombieEdge returns whether the edge is considered zombie.
func (c *ChannelGraph) IsZombieEdge(chanID uint64) (bool, [33]byte, [33]byte,
error) {
func (c *ChannelGraph) IsZombieEdge(ctx context.Context,
chanID uint64) (bool, [33]byte, [33]byte, error) {
return c.db.IsZombieEdge(lnwire.GossipVersion1, chanID)
return c.db.IsZombieEdge(ctx, lnwire.GossipVersion1, chanID)
}
// NumZombies returns the current number of zombie channels in the graph.
@@ -829,10 +829,10 @@ func (c *VersionedGraph) FetchChannelEdgesByOutpoint(op *wire.OutPoint) (
}
// IsZombieEdge returns whether the edge is considered zombie for this version.
func (c *VersionedGraph) IsZombieEdge(chanID uint64) (bool, [33]byte,
[33]byte, error) {
func (c *VersionedGraph) IsZombieEdge(ctx context.Context,
chanID uint64) (bool, [33]byte, [33]byte, error) {
return c.db.IsZombieEdge(c.v, chanID)
return c.db.IsZombieEdge(ctx, c.v, chanID)
}
// AddrsForNode returns all known addresses for the target node public key.
+10 -6
View File
@@ -714,7 +714,7 @@ func testEdgeInsertionDeletion(t *testing.T, v lnwire.GossipVersion) {
require.ErrorIs(t, err, ErrZombieEdge)
require.NotNil(t, edge)
isZombie, _, _, err := graph.IsZombieEdge(chanID)
isZombie, _, _, err := graph.IsZombieEdge(ctx, chanID)
require.NoError(t, err)
require.True(t, isZombie)
@@ -2940,7 +2940,9 @@ func TestFilterKnownChanIDsZombieRevival(t *testing.T) {
)
isZombie := func(scid lnwire.ShortChannelID) bool {
zombie, _, _, err := graph.IsZombieEdge(scid.ToUint64())
zombie, _, _, err := graph.IsZombieEdge(
ctx, scid.ToUint64(),
)
require.NoError(t, err)
return zombie
@@ -4562,7 +4564,7 @@ func TestGraphZombieIndex(t *testing.T) {
// Since the edge is known the graph and it isn't a zombie, IsZombieEdge
// should not report the channel as a zombie.
isZombie, _, _, err := graph.IsZombieEdge(edge.ChannelID)
isZombie, _, _, err := graph.IsZombieEdge(ctx, edge.ChannelID)
require.NoError(t, err)
require.False(t, isZombie)
assertNumZombies(t, graph, 0)
@@ -4571,7 +4573,9 @@ func TestGraphZombieIndex(t *testing.T) {
// to see it within the index.
err = graph.DeleteChannelEdges(false, true, edge.ChannelID)
require.NoError(t, err, "unable to mark edge as zombie")
isZombie, pubKey1, pubKey2, err := graph.IsZombieEdge(edge.ChannelID)
isZombie, pubKey1, pubKey2, err := graph.IsZombieEdge(
ctx, edge.ChannelID,
)
require.NoError(t, err)
require.True(t, isZombie)
require.Equal(t, node1.PubKeyBytes, pubKey1)
@@ -4589,7 +4593,7 @@ func TestGraphZombieIndex(t *testing.T) {
ErrZombieEdgeNotFound,
)
isZombie, _, _, err = graph.IsZombieEdge(edge.ChannelID)
isZombie, _, _, err = graph.IsZombieEdge(ctx, edge.ChannelID)
require.NoError(t, err)
require.False(t, isZombie)
@@ -4602,7 +4606,7 @@ func TestGraphZombieIndex(t *testing.T) {
)
require.NoError(t, err, "unable to mark edge as zombie")
isZombie, _, _, err = graph.IsZombieEdge(edge.ChannelID)
isZombie, _, _, err = graph.IsZombieEdge(ctx, edge.ChannelID)
require.NoError(t, err)
require.True(t, isZombie)
assertNumZombies(t, graph, 1)
+2 -2
View File
@@ -334,8 +334,8 @@ type Store interface { //nolint:interfacebloat
// IsZombieEdge returns whether the edge is considered zombie. If it is
// a zombie, then the two node public keys corresponding to this edge
// are also returned.
IsZombieEdge(v lnwire.GossipVersion, chanID uint64) (bool, [33]byte,
[33]byte, error)
IsZombieEdge(ctx context.Context, v lnwire.GossipVersion,
chanID uint64) (bool, [33]byte, [33]byte, error)
// NumZombies returns the current number of zombie channels in the
// graph.
+1 -1
View File
@@ -4344,7 +4344,7 @@ func (c *KVStore) markEdgeLiveUnsafe(tx kvdb.RwTx, 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 are also
// returned.
func (c *KVStore) IsZombieEdge(v lnwire.GossipVersion,
func (c *KVStore) IsZombieEdge(_ context.Context, v lnwire.GossipVersion,
chanID uint64) (bool, [33]byte, [33]byte, error) {
var (
+1 -2
View File
@@ -1865,11 +1865,10 @@ func (s *SQLStore) MarkEdgeLive(ctx context.Context, chanID uint64) error {
// returned.
//
// NOTE: part of the Store interface.
func (s *SQLStore) IsZombieEdge(v lnwire.GossipVersion,
func (s *SQLStore) IsZombieEdge(ctx context.Context, v lnwire.GossipVersion,
chanID uint64) (bool, [33]byte, [33]byte, error) {
var (
ctx = context.TODO()
isZombie bool
pubKey1, pubKey2 route.Vertex
chanIDB = channelIDToBytes(chanID)