graphdb: pass context to IsPublicNode

This commit is contained in:
Elle Mouton committed 2026-02-25 16:11:42 +02:00
1 parent 397330cbdb
commit f62ea62cfe
8 files changed
+26 -18

No files matched your search

+1 -1
View File
@@ -1331,7 +1331,7 @@ func (b *Builder) IsStaleNode(ctx context.Context, node route.Vertex,
//
// NOTE: This method is part of the ChannelGraphSource interface.
func (b *Builder) IsPublicNode(node route.Vertex) (bool, error) {
return b.v1Graph.IsPublicNode(node)
return b.v1Graph.IsPublicNode(context.TODO(), node)
}
// IsKnownEdge returns true if the graph source already knows of the passed
+8 -4
View File
@@ -652,8 +652,10 @@ func (c *ChannelGraph) HasV1Node(ctx context.Context,
}
// IsPublicNode determines whether the node is seen as public in the graph.
func (c *ChannelGraph) IsPublicNode(pubKey [33]byte) (bool, error) {
return c.db.IsPublicNode(lnwire.GossipVersion1, pubKey)
func (c *ChannelGraph) IsPublicNode(ctx context.Context,
pubKey [33]byte) (bool, error) {
return c.db.IsPublicNode(ctx, lnwire.GossipVersion1, pubKey)
}
// ForEachChannel iterates through all channel edges stored within the graph.
@@ -993,8 +995,10 @@ func (c *VersionedGraph) ChannelID(ctx context.Context,
}
// IsPublicNode determines whether the node is seen as public in the graph.
func (c *VersionedGraph) IsPublicNode(pubKey [33]byte) (bool, error) {
return c.db.IsPublicNode(c.v, pubKey)
func (c *VersionedGraph) IsPublicNode(ctx context.Context,
pubKey [33]byte) (bool, error) {
return c.db.IsPublicNode(ctx, c.v, pubKey)
}
// MakeTestGraph creates a new instance of the ChannelGraph for testing
+3 -3
View File
@@ -4225,7 +4225,7 @@ func testNodeIsPublic(t *testing.T, v lnwire.GossipVersion) {
for _, node := range nodes {
for _, graph := range graphs {
isPublic, err := graph.IsPublicNode(
node.PubKeyBytes,
ctx, node.PubKeyBytes,
)
require.NoError(t, err)
@@ -4330,7 +4330,7 @@ func testIsPublicNodeEmptyChannelSignature(t *testing.T,
// node1 should NOT be considered public because the
// channel announcement has empty signatures.
isPublic, err := graph.IsPublicNode(node1.PubKeyBytes)
isPublic, err := graph.IsPublicNode(ctx, node1.PubKeyBytes)
require.NoError(t, err)
require.False(t, isPublic)
}
@@ -4354,7 +4354,7 @@ func BenchmarkIsPublicNode(b *testing.B) {
// Query random nodes to avoid query caching and better
// represent real-world query patterns.
nodePub := nodes[rng.Intn(len(nodes))].PubKeyBytes
_, err := graph.IsPublicNode(nodePub)
_, err := graph.IsPublicNode(b.Context(), nodePub)
require.NoError(b, err)
}
}
+2 -1
View File
@@ -150,7 +150,8 @@ type Store interface { //nolint:interfacebloat
// IsPublicNode is a helper method that determines whether the node with
// the given public key is seen as a public node in the graph from the
// graph's source node's point of view.
IsPublicNode(v lnwire.GossipVersion, pubKey [33]byte) (bool, error)
IsPublicNode(ctx context.Context, v lnwire.GossipVersion,
pubKey [33]byte) (bool, error)
// GraphSession will provide the call-back with access to a
// NodeTraverser instance which can be used to perform queries against
+2 -2
View File
@@ -4103,8 +4103,8 @@ func (c *KVStore) FetchChannelEdgesByID(_ context.Context,
// IsPublicNode is a helper method that determines whether the node with the
// given public key is seen as a public node in the graph from the graph's
// source node's point of view.
func (c *KVStore) IsPublicNode(v lnwire.GossipVersion, pubKey [33]byte) (bool,
error) {
func (c *KVStore) IsPublicNode(_ context.Context, v lnwire.GossipVersion,
pubKey [33]byte) (bool, error) {
if v != lnwire.GossipVersion1 {
return false, ErrVersionNotSupportedForKVDB
+2 -3
View File
@@ -2546,10 +2546,9 @@ func (s *SQLStore) ChannelID(ctx context.Context, v lnwire.GossipVersion,
// source node's point of view.
//
// NOTE: part of the Store interface.
func (s *SQLStore) IsPublicNode(v lnwire.GossipVersion, pubKey [33]byte) (bool,
error) {
func (s *SQLStore) IsPublicNode(ctx context.Context, v lnwire.GossipVersion,
pubKey [33]byte) (bool, error) {
ctx := context.TODO()
if !isKnownGossipVersion(v) {
return false, fmt.Errorf("unsupported gossip version: %d", v)
}
+7 -3
View File
@@ -795,9 +795,13 @@ func newSelectHopHintsCfg(invoicesCfg *AddInvoiceConfig,
maxHopHints int) *SelectHopHintsCfg {
return &SelectHopHintsCfg{
FetchAllChannels: invoicesCfg.ChanDB.FetchAllChannels,
IsChannelActive: invoicesCfg.IsChannelActive,
IsPublicNode: invoicesCfg.Graph.IsPublicNode,
FetchAllChannels: invoicesCfg.ChanDB.FetchAllChannels,
IsChannelActive: invoicesCfg.IsChannelActive,
IsPublicNode: func(pubKey [33]byte) (bool, error) {
return invoicesCfg.Graph.IsPublicNode(
context.TODO(), pubKey,
)
},
FetchChannelEdgesByID: func(chanID uint64) (
*models.ChannelEdgeInfo, *models.ChannelEdgePolicy,
*models.ChannelEdgePolicy, error) {
+1 -1
View File
@@ -18,5 +18,5 @@ type GraphSource interface {
// IsPublicNode is a helper method that determines whether the node with
// the given public key is seen as a public node in the graph from the
// graph's source node's point of view.
IsPublicNode(pubKey [33]byte) (bool, error)
IsPublicNode(ctx context.Context, pubKey [33]byte) (bool, error)
}