multi: thread context through to AddrsForNode

This commit is contained in:
Elle Mouton committed 2025-06-17 19:20:59 +02:00
1 parent d1fa5701eb
commit e724e1c3e4
15 files changed
+88 -64

No files matched your search

+3 -3
View File
@@ -183,7 +183,7 @@ func TestNodeInsertionAndDeletion(t *testing.T) {
// Initially, the node is unknown to the graph and there should be no
// addresses for it.
known, addrs, err := graph.AddrsForNode(pub)
known, addrs, err := graph.AddrsForNode(ctx, pub)
require.NoError(t, err)
require.False(t, known)
require.Empty(t, addrs)
@@ -197,7 +197,7 @@ func TestNodeInsertionAndDeletion(t *testing.T) {
require.NoError(t, err)
require.Empty(t, dbNode.Addresses)
known, addrs, err = graph.AddrsForNode(pub)
known, addrs, err = graph.AddrsForNode(ctx, pub)
require.NoError(t, err)
require.True(t, known)
require.Empty(t, addrs)
@@ -224,7 +224,7 @@ func TestNodeInsertionAndDeletion(t *testing.T) {
require.NoError(t, err)
require.Equal(t, expAddrs, dbNode.Addresses)
known, addrs, err = graph.AddrsForNode(pub)
known, addrs, err = graph.AddrsForNode(ctx, pub)
require.NoError(t, err)
require.True(t, known)
require.EqualValues(t, expAddrs, addrs)
+2 -1
View File
@@ -63,7 +63,8 @@ type V1Store interface { //nolint:interfacebloat
// AddrsForNode returns all known addresses for the target node public
// key that the graph DB is aware of. The returned boolean indicates if
// the given node is unknown to the graph DB or not.
AddrsForNode(nodePub *btcec.PublicKey) (bool, []net.Addr, error)
AddrsForNode(ctx context.Context,
nodePub *btcec.PublicKey) (bool, []net.Addr, error)
// ForEachSourceNodeChannel iterates through all channels of the source
// node, executing the passed callback on each. The call-back is
+2 -4
View File
@@ -376,10 +376,8 @@ func initKVStore(db kvdb.Backend) error {
// unknown to the graph DB or not.
//
// NOTE: this is part of the channeldb.AddrSource interface.
func (c *KVStore) AddrsForNode(nodePub *btcec.PublicKey) (bool, []net.Addr,
error) {
ctx := context.TODO()
func (c *KVStore) AddrsForNode(ctx context.Context,
nodePub *btcec.PublicKey) (bool, []net.Addr, error) {
pubKey, err := route.NewVertexFromBytes(nodePub.SerializeCompressed())
if err != nil {
+2 -4
View File
@@ -258,10 +258,8 @@ func (s *SQLStore) HasLightningNode(ctx context.Context,
// given node is unknown to the graph DB or not.
//
// NOTE: part of the V1Store interface.
func (s *SQLStore) AddrsForNode(nodePub *btcec.PublicKey) (bool, []net.Addr,
error) {
ctx := context.TODO()
func (s *SQLStore) AddrsForNode(ctx context.Context,
nodePub *btcec.PublicKey) (bool, []net.Addr, error) {
var (
addresses []net.Addr