graphdb: pass context to ChannelView

This commit is contained in:
Elle Mouton committed 2026-02-25 16:11:46 +02:00
1 parent 7dbaa691c4
commit 9f855175d5
6 files changed
+10 -13

No files matched your search

+1 -1
View File
@@ -231,7 +231,7 @@ func (b *Builder) Start() error {
// FilteredChainView instance. We do this before, as otherwise
// we may miss on-chain events as the filter hasn't properly
// been applied.
channelView, err := b.cfg.Graph.ChannelView()
channelView, err := b.cfg.Graph.ChannelView(context.TODO())
if err != nil && !errors.Is(
err, graphdb.ErrGraphNoEdgesFound,
) {
+2 -2
View File
@@ -755,8 +755,8 @@ func (c *ChannelGraph) FetchChannelEdgesByID(ctx context.Context,
}
// ChannelView returns the verifiable edge information for each active channel.
func (c *ChannelGraph) ChannelView() ([]EdgePoint, error) {
return c.db.ChannelView()
func (c *ChannelGraph) ChannelView(ctx context.Context) ([]EdgePoint, error) {
return c.db.ChannelView(ctx)
}
// IsZombieEdge returns whether the edge is considered zombie.
+3 -3
View File
@@ -2274,7 +2274,7 @@ func TestGraphPruning(t *testing.T) {
// With all the channel points added, we'll consult the graph to ensure
// it has the same channel view as the one we just constructed.
channelView, err := graph.ChannelView()
channelView, err := graph.ChannelView(ctx)
require.NoError(t, err, "unable to get graph channel view")
assertChanViewEqual(t, channelView, edgePoints)
@@ -2301,7 +2301,7 @@ func TestGraphPruning(t *testing.T) {
assertNumChans(t, graph, 2)
// Those channels should also be missing from the channel view.
channelView, err = graph.ChannelView()
channelView, err = graph.ChannelView(ctx)
require.NoError(t, err, "unable to get graph channel view")
assertChanViewEqualChanPoints(t, channelView, channelPoints[2:])
@@ -2350,7 +2350,7 @@ func TestGraphPruning(t *testing.T) {
// Finally, the channel view at this point in the graph should now be
// completely empty. Those channels should also be missing from the
// channel view.
channelView, err = graph.ChannelView()
channelView, err = graph.ChannelView(ctx)
require.NoError(t, err, "unable to get graph channel view")
require.Empty(t, channelView)
}
+1 -1
View File
@@ -323,7 +323,7 @@ type Store interface { //nolint:interfacebloat
// channel within the known channel graph. The set of UTXO's (along with
// their scripts) returned are the ones that need to be watched on chain
// to detect channel closes on the resident blockchain.
ChannelView() ([]EdgePoint, error)
ChannelView(ctx context.Context) ([]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
+1 -1
View File
@@ -4180,7 +4180,7 @@ func (e *EdgePoint) String() string {
// within the known channel graph. The set of UTXO's (along with their scripts)
// returned are the ones that need to be watched on chain to detect channel
// closes on the resident blockchain.
func (c *KVStore) ChannelView() ([]EdgePoint, error) {
func (c *KVStore) ChannelView(_ context.Context) ([]EdgePoint, error) {
var edgePoints []EdgePoint
if err := kvdb.View(c.db, func(tx kvdb.RTx) error {
// We're going to iterate over the entire channel index, so
+2 -5
View File
@@ -2985,11 +2985,8 @@ func (s *SQLStore) deleteChannels(ctx context.Context, db SQLQueries,
// closes on the resident blockchain.
//
// NOTE: part of the Store interface.
func (s *SQLStore) ChannelView() ([]EdgePoint, error) {
var (
ctx = context.TODO()
edgePoints []EdgePoint
)
func (s *SQLStore) ChannelView(ctx context.Context) ([]EdgePoint, error) {
var edgePoints []EdgePoint
err := s.db.ExecTx(ctx, sqldb.ReadTxOpt(), func(db SQLQueries) error {
handleChannel := func(_ context.Context,