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