Skip to content

Commit 636b36c

Browse files
committed
graph/db: use PreferHighest for channel fetches and add GetVersions wrappers
Switch FetchChannelEdgesByID and FetchChannelEdgesByOutpoint on ChannelGraph to use the PreferHighest store variants so that callers get the highest available gossip version without needing to specify one. Also add GetVersionsBySCID and GetVersionsByOutpoint convenience wrappers on ChannelGraph that delegate to the corresponding Store methods.
1 parent afb8247 commit 636b36c

1 file changed

Lines changed: 21 additions & 8 deletions

File tree

graph/db/graph.go

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -773,26 +773,39 @@ func (c *ChannelGraph) FetchChanInfos(ctx context.Context,
773773
}
774774

775775
// FetchChannelEdgesByOutpoint attempts to lookup directed edges by funding
776-
// outpoint.
776+
// outpoint, returning the highest available gossip version.
777777
func (c *ChannelGraph) FetchChannelEdgesByOutpoint(ctx context.Context,
778778
op *wire.OutPoint) (
779779
*models.ChannelEdgeInfo, *models.ChannelEdgePolicy,
780780
*models.ChannelEdgePolicy, error) {
781781

782-
return c.db.FetchChannelEdgesByOutpoint(
783-
ctx, lnwire.GossipVersion1, op,
784-
)
782+
return c.db.FetchChannelEdgesByOutpointPreferHighest(ctx, op)
785783
}
786784

787-
// FetchChannelEdgesByID attempts to lookup directed edges by channel ID.
785+
// FetchChannelEdgesByID attempts to lookup directed edges by channel ID,
786+
// returning the highest available gossip version.
788787
func (c *ChannelGraph) FetchChannelEdgesByID(ctx context.Context,
789788
chanID uint64) (
790789
*models.ChannelEdgeInfo, *models.ChannelEdgePolicy,
791790
*models.ChannelEdgePolicy, error) {
792791

793-
return c.db.FetchChannelEdgesByID(
794-
ctx, lnwire.GossipVersion1, chanID,
795-
)
792+
return c.db.FetchChannelEdgesByIDPreferHighest(ctx, chanID)
793+
}
794+
795+
// GetVersionsBySCID returns the list of gossip versions for which a channel
796+
// with the given SCID exists in the database.
797+
func (c *ChannelGraph) GetVersionsBySCID(ctx context.Context,
798+
chanID uint64) ([]lnwire.GossipVersion, error) {
799+
800+
return c.db.GetVersionsBySCID(ctx, chanID)
801+
}
802+
803+
// GetVersionsByOutpoint returns the list of gossip versions for which a channel
804+
// with the given funding outpoint exists in the database.
805+
func (c *ChannelGraph) GetVersionsByOutpoint(ctx context.Context,
806+
op *wire.OutPoint) ([]lnwire.GossipVersion, error) {
807+
808+
return c.db.GetVersionsByOutpoint(ctx, op)
796809
}
797810

798811
// PutClosedScid stores a SCID for a closed channel in the database.

0 commit comments

Comments
 (0)