What changed, and why it matters
This commit is a routine code cleanup: it threads a request-scoped cancellation context through the AddEdgeProof function instead of creating a blank context.TODO() inside the SQL database path. There is no security-relevant behavior change; it simply lets callers pass their own context for timeouts and cancellation.
No security action required; treat as normal refactoring.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change updates the Store/ChannelGraph interface and all implementations (KVStore, SQLStore, ChannelGraph, Builder, tests) so AddEdgeProof accepts a context.Context parameter. The SQL implementation previously used context.TODO(); now it uses the caller-provided context. The KV implementation ignores the context. No logic, validation, or access-control rules are modified.
Changed components
graph/builder.gograph/db/graph.gograph/db/interfaces.gograph/db/kv_store.gograph/db/sql_store.gograph/db/graph_test.goInspect captured patch +9 / −10
diff --git a/graph/builder.go b/graph/builder.go
index a47cc18..391195f 100644
--- a/graph/builder.go
+++ b/graph/builder.go
@@ -1312,7 +1312,7 @@ func (b *Builder) ForAllOutgoingChannels(ctx context.Context,
func (b *Builder) AddProof(chanID lnwire.ShortChannelID,
proof *models.ChannelAuthProof) error {
- return b.cfg.Graph.AddEdgeProof(chanID, proof)
+ return b.cfg.Graph.AddEdgeProof(context.TODO(), chanID, proof)
}
// IsStaleNode returns true if the graph source has a node announcement for the
diff --git a/graph/db/graph.go b/graph/db/graph.go
index c42f543..66ab6d9 100644
--- a/graph/db/graph.go
+++ b/graph/db/graph.go
@@ -692,10 +692,10 @@ func (c *ChannelGraph) HasChannelEdge(ctx context.Context,
}
// AddEdgeProof sets the proof of an existing edge in the graph database.
-func (c *ChannelGraph) AddEdgeProof(chanID lnwire.ShortChannelID,
- proof *models.ChannelAuthProof) error {
+func (c *ChannelGraph) AddEdgeProof(ctx context.Context,
+ chanID lnwire.ShortChannelID, proof *models.ChannelAuthProof) error {
- return c.db.AddEdgeProof(chanID, proof)
+ return c.db.AddEdgeProof(ctx, chanID, proof)
}
// HighestChanID returns the "highest" known channel ID in the channel graph.
diff --git a/graph/db/graph_test.go b/graph/db/graph_test.go
index d9c26a9..d25289b 100644
--- a/graph/db/graph_test.go
+++ b/graph/db/graph_test.go
@@ -1611,7 +1611,7 @@ func testAddEdgeProof(t *testing.T, v lnwire.GossipVersion) {
// Now add just the proof via AddEdgeProof.
scid1 := lnwire.NewShortChanIDFromInt(edge1.ChannelID)
- require.NoError(t, graph.AddEdgeProof(scid1, proof))
+ require.NoError(t, graph.AddEdgeProof(ctx, scid1, proof))
// Fetch the edge again and assert that the proof is now set.
dbEdge, _, _, err = graph.FetchChannelEdgesByID(
diff --git a/graph/db/interfaces.go b/graph/db/interfaces.go
index 615b2cb..eb3f7e9 100644
--- a/graph/db/interfaces.go
+++ b/graph/db/interfaces.go
@@ -237,7 +237,7 @@ type Store interface { //nolint:interfacebloat
// AddEdgeProof sets the proof of an existing edge in the graph
// database.
- AddEdgeProof(chanID lnwire.ShortChannelID,
+ AddEdgeProof(ctx context.Context, chanID lnwire.ShortChannelID,
proof *models.ChannelAuthProof) error
// ChannelID attempt to lookup the 8-byte compact channel ID which maps
diff --git a/graph/db/kv_store.go b/graph/db/kv_store.go
index 7a57db6..35842ec 100644
--- a/graph/db/kv_store.go
+++ b/graph/db/kv_store.go
@@ -1440,7 +1440,7 @@ func (c *KVStore) HasChannelEdge(ctx context.Context, v lnwire.GossipVersion,
}
// AddEdgeProof sets the proof of an existing edge in the graph database.
-func (c *KVStore) AddEdgeProof(chanID lnwire.ShortChannelID,
+func (c *KVStore) AddEdgeProof(_ context.Context, chanID lnwire.ShortChannelID,
proof *models.ChannelAuthProof) error {
// We only support v1 channel proofs in the KVStore.
diff --git a/graph/db/sql_store.go b/graph/db/sql_store.go
index f1aad75..78ef82c 100644
--- a/graph/db/sql_store.go
+++ b/graph/db/sql_store.go
@@ -3198,8 +3198,8 @@ func (s *SQLStore) DisconnectBlockAtHeight(ctx context.Context,
// AddEdgeProof sets the proof of an existing edge in the graph database.
//
// NOTE: part of the Store interface.
-func (s *SQLStore) AddEdgeProof(scid lnwire.ShortChannelID,
- proof *models.ChannelAuthProof) error {
+func (s *SQLStore) AddEdgeProof(ctx context.Context,
+ scid lnwire.ShortChannelID, proof *models.ChannelAuthProof) error {
if !isKnownGossipVersion(proof.Version) {
return fmt.Errorf("unsupported gossip version: %d",
@@ -3207,7 +3207,6 @@ func (s *SQLStore) AddEdgeProof(scid lnwire.ShortChannelID,
}
var (
- ctx = context.TODO()
scidBytes = channelIDToBytes(scid.ToUint64())
)
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.