graphdb: pass context to FetchChanInfos
This commit is contained in:
7 files changed
+14
-15
No files matched your search
@@ -261,7 +261,7 @@ func (c *ChanSeries) FetchChanAnns(chain chainhash.Hash,
|
|||||||
chanIDs = append(chanIDs, chanID.ToUint64())
|
chanIDs = append(chanIDs, chanID.ToUint64())
|
||||||
}
|
}
|
||||||
|
|
||||||
channels, err := c.graph.FetchChanInfos(chanIDs)
|
channels, err := c.graph.FetchChanInfos(context.TODO(), chanIDs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -582,7 +582,7 @@ func (b *Builder) pruneZombieChans() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
disabledEdges, err := b.v1Graph.FetchChanInfos(
|
disabledEdges, err := b.v1Graph.FetchChanInfos(
|
||||||
disabledChanIDs,
|
context.TODO(), disabledChanIDs,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to fetch disabled channels "+
|
return fmt.Errorf("unable to fetch disabled channels "+
|
||||||
|
|||||||
+7
-7
@@ -353,7 +353,7 @@ func (c *ChannelGraph) MarkEdgeLive(ctx context.Context, chanID uint64) error {
|
|||||||
// We need to add the channel back into our graph cache,
|
// We need to add the channel back into our graph cache,
|
||||||
// otherwise we won't use it for path finding.
|
// otherwise we won't use it for path finding.
|
||||||
infos, err := c.db.FetchChanInfos(
|
infos, err := c.db.FetchChanInfos(
|
||||||
lnwire.GossipVersion1, []uint64{chanID},
|
ctx, lnwire.GossipVersion1, []uint64{chanID},
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -723,10 +723,10 @@ func (c *ChannelGraph) FilterChannelRange(ctx context.Context,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FetchChanInfos returns the set of channel edges for the passed channel IDs.
|
// FetchChanInfos returns the set of channel edges for the passed channel IDs.
|
||||||
func (c *ChannelGraph) FetchChanInfos(v lnwire.GossipVersion,
|
func (c *ChannelGraph) FetchChanInfos(ctx context.Context,
|
||||||
chanIDs []uint64) ([]ChannelEdge, error) {
|
v lnwire.GossipVersion, chanIDs []uint64) ([]ChannelEdge, error) {
|
||||||
|
|
||||||
return c.db.FetchChanInfos(v, chanIDs)
|
return c.db.FetchChanInfos(ctx, v, chanIDs)
|
||||||
}
|
}
|
||||||
|
|
||||||
// FetchChannelEdgesByOutpoint attempts to lookup directed edges by funding
|
// FetchChannelEdgesByOutpoint attempts to lookup directed edges by funding
|
||||||
@@ -976,10 +976,10 @@ func (c *VersionedGraph) DisabledChannelIDs(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FetchChanInfos returns the set of channel edges for the passed channel IDs.
|
// FetchChanInfos returns the set of channel edges for the passed channel IDs.
|
||||||
func (c *VersionedGraph) FetchChanInfos(chanIDs []uint64) ([]ChannelEdge,
|
func (c *VersionedGraph) FetchChanInfos(ctx context.Context,
|
||||||
error) {
|
chanIDs []uint64) ([]ChannelEdge, error) {
|
||||||
|
|
||||||
return c.db.FetchChanInfos(c.v, chanIDs)
|
return c.db.FetchChanInfos(ctx, c.v, chanIDs)
|
||||||
}
|
}
|
||||||
|
|
||||||
// HighestChanID returns the "highest" known channel ID in the channel graph.
|
// HighestChanID returns the "highest" known channel ID in the channel graph.
|
||||||
|
|||||||
@@ -3785,7 +3785,7 @@ func testFetchChanInfos(t *testing.T, v lnwire.GossipVersion) {
|
|||||||
// We'll now attempt to query for the range of channel ID's we just
|
// We'll now attempt to query for the range of channel ID's we just
|
||||||
// inserted into the database. We should get the exact same set of
|
// inserted into the database. We should get the exact same set of
|
||||||
// edges back.
|
// edges back.
|
||||||
resp, err := graph.FetchChanInfos(edgeQuery)
|
resp, err := graph.FetchChanInfos(ctx, edgeQuery)
|
||||||
require.NoError(t, err, "unable to fetch chan edges")
|
require.NoError(t, err, "unable to fetch chan edges")
|
||||||
require.Len(t, resp, len(edges))
|
require.Len(t, resp, len(edges))
|
||||||
|
|
||||||
|
|||||||
@@ -288,7 +288,7 @@ type Store interface { //nolint:interfacebloat
|
|||||||
// edges that exist at the time of the query. This can be used to
|
// edges that exist at the time of the query. This can be used to
|
||||||
// respond to peer queries that are seeking to fill in gaps in their
|
// respond to peer queries that are seeking to fill in gaps in their
|
||||||
// view of the channel graph.
|
// view of the channel graph.
|
||||||
FetchChanInfos(v lnwire.GossipVersion,
|
FetchChanInfos(ctx context.Context, v lnwire.GossipVersion,
|
||||||
chanIDs []uint64) ([]ChannelEdge, error)
|
chanIDs []uint64) ([]ChannelEdge, error)
|
||||||
|
|
||||||
// FetchChannelEdgesByOutpoint attempts to lookup the two directed edges
|
// FetchChannelEdgesByOutpoint attempts to lookup the two directed edges
|
||||||
|
|||||||
@@ -2963,7 +2963,7 @@ func (c *KVStore) FilterChannelRange(_ context.Context, startHeight,
|
|||||||
// skipped and the result will contain only those edges that exist at the time
|
// skipped and the result will contain only those edges that exist at the time
|
||||||
// of the query. This can be used to respond to peer queries that are seeking to
|
// of the query. This can be used to respond to peer queries that are seeking to
|
||||||
// fill in gaps in their view of the channel graph.
|
// fill in gaps in their view of the channel graph.
|
||||||
func (c *KVStore) FetchChanInfos(v lnwire.GossipVersion,
|
func (c *KVStore) FetchChanInfos(_ context.Context, v lnwire.GossipVersion,
|
||||||
chanIDs []uint64) ([]ChannelEdge, error) {
|
chanIDs []uint64) ([]ChannelEdge, error) {
|
||||||
|
|
||||||
if v != lnwire.GossipVersion1 {
|
if v != lnwire.GossipVersion1 {
|
||||||
|
|||||||
@@ -2580,11 +2580,10 @@ func (s *SQLStore) IsPublicNode(ctx context.Context, v lnwire.GossipVersion,
|
|||||||
// fill in gaps in their view of the channel graph.
|
// fill in gaps in their view of the channel graph.
|
||||||
//
|
//
|
||||||
// NOTE: part of the Store interface.
|
// NOTE: part of the Store interface.
|
||||||
func (s *SQLStore) FetchChanInfos(v lnwire.GossipVersion,
|
func (s *SQLStore) FetchChanInfos(ctx context.Context,
|
||||||
chanIDs []uint64) ([]ChannelEdge, error) {
|
v lnwire.GossipVersion, chanIDs []uint64) ([]ChannelEdge, error) {
|
||||||
|
|
||||||
var (
|
var (
|
||||||
ctx = context.TODO()
|
|
||||||
edges = make(map[uint64]ChannelEdge)
|
edges = make(map[uint64]ChannelEdge)
|
||||||
)
|
)
|
||||||
err := s.db.ExecTx(ctx, sqldb.ReadTxOpt(), func(db SQLQueries) error {
|
err := s.db.ExecTx(ctx, sqldb.ReadTxOpt(), func(db SQLQueries) error {
|
||||||
|
|||||||
Reference in new issue
Block a user