graph/db: thread context through to LookupAlias

This commit is contained in:
Elle Mouton committed 2025-06-19 14:49:32 +02:00
1 parent 81c063eb96
commit 004440a86c
5 files changed
+18 -13

No files matched your search

+2 -2
View File
@@ -348,7 +348,7 @@ func TestAliasLookup(t *testing.T) {
// the one which the test node was assigned.
nodePub, err := testNode.PubKey()
require.NoError(t, err, "unable to generate pubkey")
dbAlias, err := graph.LookupAlias(nodePub)
dbAlias, err := graph.LookupAlias(ctx, nodePub)
require.NoError(t, err, "unable to find alias")
require.Equal(t, testNode.Alias, dbAlias)
@@ -356,7 +356,7 @@ func TestAliasLookup(t *testing.T) {
node := createTestVertex(t)
nodePub, err = node.PubKey()
require.NoError(t, err, "unable to generate pubkey")
_, err = graph.LookupAlias(nodePub)
_, err = graph.LookupAlias(ctx, nodePub)
require.ErrorIs(t, err, ErrNodeAliasNotFound)
}
+1 -1
View File
@@ -111,7 +111,7 @@ type V1Store interface { //nolint:interfacebloat
// LookupAlias attempts to return the alias as advertised by the target
// node.
LookupAlias(pub *btcec.PublicKey) (string, error)
LookupAlias(ctx context.Context, pub *btcec.PublicKey) (string, error)
// DeleteLightningNode starts a new database transaction to remove a
// vertex/node from the database according to the node's public key.
+3 -1
View File
@@ -997,7 +997,9 @@ func addLightningNode(tx kvdb.RwTx, node *models.LightningNode) error {
// LookupAlias attempts to return the alias as advertised by the target node.
// TODO(roasbeef): currently assumes that aliases are unique...
func (c *KVStore) LookupAlias(pub *btcec.PublicKey) (string, error) {
func (c *KVStore) LookupAlias(_ context.Context,
pub *btcec.PublicKey) (string, error) {
var alias string
err := kvdb.View(c.db, func(tx kvdb.RTx) error {
+4 -5
View File
@@ -355,11 +355,10 @@ func (s *SQLStore) FetchNodeFeatures(nodePub route.Vertex) (
// LookupAlias attempts to return the alias as advertised by the target node.
//
// NOTE: part of the V1Store interface.
func (s *SQLStore) LookupAlias(pub *btcec.PublicKey) (string, error) {
var (
ctx = context.TODO()
alias string
)
func (s *SQLStore) LookupAlias(ctx context.Context,
pub *btcec.PublicKey) (string, error) {
var alias string
err := s.db.ExecTx(ctx, sqldb.ReadTxOpt(), func(db SQLQueries) error {
dbNode, err := db.GetNodeByPubKey(
ctx, sqlc.GetNodeByPubKeyParams{