diff --git a/channeldb/graph.go b/channeldb/graph.go index 227d5fadd..0ac0ec2f7 100644 --- a/channeldb/graph.go +++ b/channeldb/graph.go @@ -2374,10 +2374,19 @@ func (c *ChannelGraph) FilterChannelRange(startHeight, // 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 // fill in gaps in their view of the channel graph. +func (c *ChannelGraph) FetchChanInfos(chanIDs []uint64) ([]ChannelEdge, error) { + return c.fetchChanInfos(nil, chanIDs) +} + +// fetchChanInfos returns the set of channel edges that correspond to the passed +// channel ID's. If an edge is the query is unknown to the database, it will +// 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 +// fill in gaps in their view of the channel graph. // // NOTE: An optional transaction may be provided. If none is provided, then a // new one will be created. -func (c *ChannelGraph) FetchChanInfos(tx kvdb.RTx, chanIDs []uint64) ( +func (c *ChannelGraph) fetchChanInfos(tx kvdb.RTx, chanIDs []uint64) ( []ChannelEdge, error) { // TODO(roasbeef): sort cids? @@ -2958,8 +2967,8 @@ func (c *ChannelGraph) isPublic(tx kvdb.RTx, nodePub route.Vertex, // key. If the node isn't found in the database, then ErrGraphNodeNotFound is // returned. An optional transaction may be provided. If none is provided, then // a new one will be created. -func (c *ChannelGraph) FetchLightningNode(tx kvdb.RTx, nodePub route.Vertex) ( - *LightningNode, error) { +func (c *ChannelGraph) FetchLightningNode(tx kvdb.RTx, + nodePub route.Vertex) (*LightningNode, error) { var node *LightningNode fetch := func(tx kvdb.RTx) error { @@ -3705,7 +3714,7 @@ func (c *ChannelGraph) markEdgeLiveUnsafe(tx kvdb.RwTx, chanID uint64) error { // We need to add the channel back into our graph cache, otherwise we // won't use it for path finding. if c.graphCache != nil { - edgeInfos, err := c.FetchChanInfos(tx, []uint64{chanID}) + edgeInfos, err := c.fetchChanInfos(tx, []uint64{chanID}) if err != nil { return err } diff --git a/channeldb/graph_test.go b/channeldb/graph_test.go index 717b99fd1..9e430296b 100644 --- a/channeldb/graph_test.go +++ b/channeldb/graph_test.go @@ -2685,7 +2685,7 @@ func TestFetchChanInfos(t *testing.T) { // 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 // edges back. - resp, err := graph.FetchChanInfos(nil, edgeQuery) + resp, err := graph.FetchChanInfos(edgeQuery) require.NoError(t, err, "unable to fetch chan edges") if len(resp) != len(edges) { t.Fatalf("expected %v edges, instead got %v", len(edges), diff --git a/discovery/chan_series.go b/discovery/chan_series.go index bd6571b87..34e6d4a9d 100644 --- a/discovery/chan_series.go +++ b/discovery/chan_series.go @@ -249,7 +249,7 @@ func (c *ChanSeries) FetchChanAnns(chain chainhash.Hash, chanIDs = append(chanIDs, chanID.ToUint64()) } - channels, err := c.graph.FetchChanInfos(nil, chanIDs) + channels, err := c.graph.FetchChanInfos(chanIDs) if err != nil { return nil, err } diff --git a/routing/router.go b/routing/router.go index 04b6cad45..c968f8d32 100644 --- a/routing/router.go +++ b/routing/router.go @@ -1023,7 +1023,7 @@ func (r *ChannelRouter) pruneZombieChans() error { } disabledEdges, err := r.cfg.Graph.FetchChanInfos( - nil, disabledChanIDs, + disabledChanIDs, ) if err != nil { return fmt.Errorf("unable to fetch disabled channels "+