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