graph/db: add version parameter to FetchChannelEdgesByID/Outpoint

Make channel edge fetching version-aware by adding gossip version
parameter to FetchChannelEdgesByID and FetchChannelEdgesByOutpoint.
Add corresponding methods to VersionedGraph. V2 policy building is
marked as TODO.
This commit is contained in:
Elle Mouton committed 2026-02-13 07:21:23 +02:00
1 parent 971c0f6eb8
commit d88fa01162
4 files changed
+73 -15

No files matched your search

+12 -4
View File
@@ -3811,8 +3811,8 @@ func computeEdgePolicyKeys(info *models.ChannelEdgeInfo) ([]byte, []byte) {
// found, then ErrEdgeNotFound is returned. A struct which houses the general
// information for the channel itself is returned as well as two structs that
// contain the routing policies for the channel in either direction.
func (c *KVStore) FetchChannelEdgesByOutpoint(op *wire.OutPoint) (
*models.ChannelEdgeInfo, *models.ChannelEdgePolicy,
func (c *KVStore) FetchChannelEdgesByOutpoint(v lnwire.GossipVersion,
op *wire.OutPoint) (*models.ChannelEdgeInfo, *models.ChannelEdgePolicy,
*models.ChannelEdgePolicy, error) {
var (
@@ -3821,6 +3821,10 @@ func (c *KVStore) FetchChannelEdgesByOutpoint(op *wire.OutPoint) (
policy2 *models.ChannelEdgePolicy
)
if v != lnwire.GossipVersion1 {
return nil, nil, nil, ErrVersionNotSupportedForKVDB
}
err := kvdb.View(c.db, func(tx kvdb.RTx) error {
// First, grab the node bucket. This will be used to populate
// the Node pointers in each edge read from disk.
@@ -3897,10 +3901,14 @@ func (c *KVStore) FetchChannelEdgesByOutpoint(op *wire.OutPoint) (
// ErrZombieEdge an be returned if the edge is currently marked as a zombie
// within the database. In this case, the ChannelEdgePolicy's will be nil, and
// the ChannelEdgeInfo will only include the public keys of each node.
func (c *KVStore) FetchChannelEdgesByID(chanID uint64) (
*models.ChannelEdgeInfo, *models.ChannelEdgePolicy,
func (c *KVStore) FetchChannelEdgesByID(v lnwire.GossipVersion,
chanID uint64) (*models.ChannelEdgeInfo, *models.ChannelEdgePolicy,
*models.ChannelEdgePolicy, error) {
if v != lnwire.GossipVersion1 {
return nil, nil, nil, ErrVersionNotSupportedForKVDB
}
var (
edgeInfo *models.ChannelEdgeInfo
policy1 *models.ChannelEdgePolicy