graphdb: pass context to ChannelID
This commit is contained in:
6 files changed
+9
-8
No files matched your search
+4
-2
@@ -986,8 +986,10 @@ func (c *VersionedGraph) HighestChanID(ctx context.Context) (uint64, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ChannelID attempts to lookup the 8-byte compact channel ID.
|
// ChannelID attempts to lookup the 8-byte compact channel ID.
|
||||||
func (c *VersionedGraph) ChannelID(chanPoint *wire.OutPoint) (uint64, error) {
|
func (c *VersionedGraph) ChannelID(ctx context.Context,
|
||||||
return c.db.ChannelID(c.v, chanPoint)
|
chanPoint *wire.OutPoint) (uint64, error) {
|
||||||
|
|
||||||
|
return c.db.ChannelID(ctx, c.v, chanPoint)
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsPublicNode determines whether the node is seen as public in the graph.
|
// IsPublicNode determines whether the node is seen as public in the graph.
|
||||||
|
|||||||
@@ -1191,7 +1191,7 @@ func testEdgeInfoUpdates(t *testing.T, v lnwire.GossipVersion) {
|
|||||||
|
|
||||||
// We should also be able to retrieve the channelID only knowing the
|
// We should also be able to retrieve the channelID only knowing the
|
||||||
// channel point of the channel.
|
// channel point of the channel.
|
||||||
dbChanID, err := graph.ChannelID(&outpoint)
|
dbChanID, err := graph.ChannelID(ctx, &outpoint)
|
||||||
require.NoError(t, err, "unable to retrieve channel ID")
|
require.NoError(t, err, "unable to retrieve channel ID")
|
||||||
require.Equal(t, chanID, dbChanID)
|
require.Equal(t, chanID, dbChanID)
|
||||||
|
|
||||||
|
|||||||
@@ -242,7 +242,7 @@ type Store interface { //nolint:interfacebloat
|
|||||||
// ChannelID attempt to lookup the 8-byte compact channel ID which maps
|
// ChannelID attempt to lookup the 8-byte compact channel ID which maps
|
||||||
// to the passed channel point (outpoint). If the passed channel doesn't
|
// to the passed channel point (outpoint). If the passed channel doesn't
|
||||||
// exist within the database, then ErrEdgeNotFound is returned.
|
// exist within the database, then ErrEdgeNotFound is returned.
|
||||||
ChannelID(v lnwire.GossipVersion,
|
ChannelID(ctx context.Context, v lnwire.GossipVersion,
|
||||||
chanPoint *wire.OutPoint) (uint64, error)
|
chanPoint *wire.OutPoint) (uint64, error)
|
||||||
|
|
||||||
// HighestChanID returns the "highest" known channel ID in the channel
|
// HighestChanID returns the "highest" known channel ID in the channel
|
||||||
|
|||||||
@@ -2006,7 +2006,7 @@ func (c *KVStore) DeleteChannelEdges(_ context.Context,
|
|||||||
// ChannelID attempt to lookup the 8-byte compact channel ID which maps to the
|
// ChannelID attempt to lookup the 8-byte compact channel ID which maps to the
|
||||||
// passed channel point (outpoint). If the passed channel doesn't exist within
|
// passed channel point (outpoint). If the passed channel doesn't exist within
|
||||||
// the database, then ErrEdgeNotFound is returned.
|
// the database, then ErrEdgeNotFound is returned.
|
||||||
func (c *KVStore) ChannelID(v lnwire.GossipVersion,
|
func (c *KVStore) ChannelID(_ context.Context, v lnwire.GossipVersion,
|
||||||
chanPoint *wire.OutPoint) (uint64, error) {
|
chanPoint *wire.OutPoint) (uint64, error) {
|
||||||
|
|
||||||
if v != lnwire.GossipVersion1 {
|
if v != lnwire.GossipVersion1 {
|
||||||
|
|||||||
@@ -2510,11 +2510,10 @@ func (s *SQLStore) HasChannelEdge(ctx context.Context,
|
|||||||
// the database, then ErrEdgeNotFound is returned.
|
// the database, then ErrEdgeNotFound is returned.
|
||||||
//
|
//
|
||||||
// NOTE: part of the Store interface.
|
// NOTE: part of the Store interface.
|
||||||
func (s *SQLStore) ChannelID(v lnwire.GossipVersion,
|
func (s *SQLStore) ChannelID(ctx context.Context, v lnwire.GossipVersion,
|
||||||
chanPoint *wire.OutPoint) (uint64, error) {
|
chanPoint *wire.OutPoint) (uint64, error) {
|
||||||
|
|
||||||
var (
|
var (
|
||||||
ctx = context.TODO()
|
|
||||||
channelID uint64
|
channelID uint64
|
||||||
)
|
)
|
||||||
err := s.db.ExecTx(ctx, sqldb.ReadTxOpt(), func(db SQLQueries) error {
|
err := s.db.ExecTx(ctx, sqldb.ReadTxOpt(), func(db SQLQueries) error {
|
||||||
|
|||||||
+1
-1
@@ -3204,7 +3204,7 @@ func abandonChanFromGraph(chanGraph *graphdb.VersionedGraph,
|
|||||||
// First, we'll obtain the channel ID. If we can't locate this, then
|
// First, we'll obtain the channel ID. If we can't locate this, then
|
||||||
// it's the case that the channel may have already been removed from
|
// it's the case that the channel may have already been removed from
|
||||||
// the graph, so we'll return a nil error.
|
// the graph, so we'll return a nil error.
|
||||||
chanID, err := chanGraph.ChannelID(chanPoint)
|
chanID, err := chanGraph.ChannelID(context.TODO(), chanPoint)
|
||||||
switch {
|
switch {
|
||||||
case errors.Is(err, graphdb.ErrEdgeNotFound):
|
case errors.Is(err, graphdb.ErrEdgeNotFound):
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
Reference in new issue
Block a user