graph/db: thread context through DisabledChannelIDs
This commit is contained in:
6 files changed
+16
-13
No files matched your search
+1
-1
@@ -574,7 +574,7 @@ func (b *Builder) pruneZombieChans() error {
|
||||
// the channel being closed and can prune it from our graph.
|
||||
if b.cfg.AssumeChannelValid {
|
||||
disabledChanIDs, err := b.cfg.Graph.DisabledChannelIDs(
|
||||
lnwire.GossipVersion1,
|
||||
context.TODO(), lnwire.GossipVersion1,
|
||||
)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to get disabled channels "+
|
||||
|
||||
+7
-4
@@ -662,10 +662,11 @@ func (c *ChannelGraph) ForEachChannel(ctx context.Context,
|
||||
}
|
||||
|
||||
// DisabledChannelIDs returns the channel ids of disabled channels.
|
||||
func (c *ChannelGraph) DisabledChannelIDs(v lnwire.GossipVersion) (
|
||||
func (c *ChannelGraph) DisabledChannelIDs(ctx context.Context,
|
||||
v lnwire.GossipVersion) (
|
||||
[]uint64, error) {
|
||||
|
||||
return c.db.DisabledChannelIDs(v)
|
||||
return c.db.DisabledChannelIDs(ctx, v)
|
||||
}
|
||||
|
||||
// HasV1ChannelEdge returns true if the database knows of a channel edge.
|
||||
@@ -952,8 +953,10 @@ func (c *VersionedGraph) ForEachChannelCacheable(
|
||||
}
|
||||
|
||||
// DisabledChannelIDs returns the channel ids of disabled channels.
|
||||
func (c *VersionedGraph) DisabledChannelIDs() ([]uint64, error) {
|
||||
return c.db.DisabledChannelIDs(c.v)
|
||||
func (c *VersionedGraph) DisabledChannelIDs(
|
||||
ctx context.Context) ([]uint64, error) {
|
||||
|
||||
return c.db.DisabledChannelIDs(ctx, c.v)
|
||||
}
|
||||
|
||||
// FetchChanInfos returns the set of channel edges for the passed channel IDs.
|
||||
|
||||
@@ -4359,7 +4359,7 @@ func testDisabledChannelIDs(t *testing.T, v lnwire.GossipVersion) {
|
||||
require.NoError(t, graph.AddChannelEdge(ctx, edgeInfo))
|
||||
|
||||
// Ensure no disabled channels exist in the bucket on start.
|
||||
disabledChanIds, err := graph.DisabledChannelIDs()
|
||||
disabledChanIds, err := graph.DisabledChannelIDs(ctx)
|
||||
require.NoError(t, err, "unable to get disabled channel ids")
|
||||
require.Empty(t, disabledChanIds)
|
||||
|
||||
@@ -4372,7 +4372,7 @@ func testDisabledChannelIDs(t *testing.T, v lnwire.GossipVersion) {
|
||||
edge1.DisableFlags |= lnwire.ChanUpdateDisableIncoming
|
||||
}
|
||||
require.NoError(t, graph.UpdateEdgePolicy(ctx, edge1))
|
||||
disabledChanIds, err = graph.DisabledChannelIDs()
|
||||
disabledChanIds, err = graph.DisabledChannelIDs(ctx)
|
||||
require.NoError(t, err, "unable to get disabled channel ids")
|
||||
require.Empty(t, disabledChanIds)
|
||||
|
||||
@@ -4385,7 +4385,7 @@ func testDisabledChannelIDs(t *testing.T, v lnwire.GossipVersion) {
|
||||
edge2.DisableFlags |= lnwire.ChanUpdateDisableIncoming
|
||||
}
|
||||
require.NoError(t, graph.UpdateEdgePolicy(ctx, edge2))
|
||||
disabledChanIds, err = graph.DisabledChannelIDs()
|
||||
disabledChanIds, err = graph.DisabledChannelIDs(ctx)
|
||||
require.NoError(t, err, "unable to get disabled channel ids")
|
||||
require.Equal(t, []uint64{edgeInfo.ChannelID}, disabledChanIds)
|
||||
|
||||
@@ -4394,7 +4394,7 @@ func testDisabledChannelIDs(t *testing.T, v lnwire.GossipVersion) {
|
||||
require.NoError(t, graph.DeleteChannelEdges(
|
||||
false, true, edgeInfo.ChannelID,
|
||||
))
|
||||
disabledChanIds, err = graph.DisabledChannelIDs()
|
||||
disabledChanIds, err = graph.DisabledChannelIDs(ctx)
|
||||
require.NoError(t, err, "unable to get disabled channel ids")
|
||||
require.Empty(t, disabledChanIds)
|
||||
}
|
||||
|
||||
@@ -191,7 +191,8 @@ type Store interface { //nolint:interfacebloat
|
||||
// DisabledChannelIDs returns the channel ids of disabled channels.
|
||||
// A channel is disabled when two of the associated ChanelEdgePolicies
|
||||
// have their disabled bit on.
|
||||
DisabledChannelIDs(v lnwire.GossipVersion) ([]uint64, error)
|
||||
DisabledChannelIDs(ctx context.Context,
|
||||
v lnwire.GossipVersion) ([]uint64, error)
|
||||
|
||||
// AddChannelEdge adds a new (undirected, blank) edge to the graph
|
||||
// database. An undirected edge from the two target nodes are created.
|
||||
|
||||
@@ -773,7 +773,7 @@ func (c *KVStore) ForEachNodeCached(ctx context.Context, withAddrs bool,
|
||||
// A channel is disabled when two of the associated ChanelEdgePolicies
|
||||
// have their disabled bit on.
|
||||
func (c *KVStore) DisabledChannelIDs(
|
||||
v lnwire.GossipVersion) ([]uint64, error) {
|
||||
_ context.Context, v lnwire.GossipVersion) ([]uint64, error) {
|
||||
|
||||
if v != lnwire.GossipVersion1 {
|
||||
return nil, ErrVersionNotSupportedForKVDB
|
||||
|
||||
@@ -460,10 +460,9 @@ func (s *SQLStore) FetchNodeFeatures(ctx context.Context,
|
||||
//
|
||||
// NOTE: part of the Store interface.
|
||||
func (s *SQLStore) DisabledChannelIDs(
|
||||
v lnwire.GossipVersion) ([]uint64, error) {
|
||||
ctx context.Context, v lnwire.GossipVersion) ([]uint64, error) {
|
||||
|
||||
var (
|
||||
ctx = context.TODO()
|
||||
chanIDs []uint64
|
||||
)
|
||||
err := s.db.ExecTx(ctx, sqldb.ReadTxOpt(), func(db SQLQueries) error {
|
||||
|
||||
Reference in new issue
Block a user