graph/db: add gossip version parameter to ForEachChannel
Update ForEachChannel to accept a gossip version parameter, allowing callers to specify which gossip version's channels should be iterated. This change prepares the graph database for supporting multiple gossip versions while maintaining backward compatibility. The KVStore implementation validates that only GossipVersion1 is requested, returning ErrVersionNotSupportedForKVDB for other versions. The SQLStore implementation validates known versions and passes the version through to the underlying paginated query. Update VersionedGraph to include a ForEachChannel method that automatically uses its configured gossip version, and update the DescribeGraph RPC handler to use the v1Graph instead of the global graphDB.
This commit is contained in:
7 files changed
+92
-65
No files matched your search
+12
-3
@@ -642,10 +642,11 @@ func (c *ChannelGraph) IsPublicNode(pubKey [33]byte) (bool, error) {
|
||||
|
||||
// ForEachChannel iterates through all channel edges stored within the graph.
|
||||
func (c *ChannelGraph) ForEachChannel(ctx context.Context,
|
||||
cb func(*models.ChannelEdgeInfo, *models.ChannelEdgePolicy,
|
||||
*models.ChannelEdgePolicy) error, reset func()) error {
|
||||
v lnwire.GossipVersion, cb func(*models.ChannelEdgeInfo,
|
||||
*models.ChannelEdgePolicy, *models.ChannelEdgePolicy) error,
|
||||
reset func()) error {
|
||||
|
||||
return c.db.ForEachChannel(ctx, cb, reset)
|
||||
return c.db.ForEachChannel(ctx, v, cb, reset)
|
||||
}
|
||||
|
||||
// ForEachChannelCacheable iterates through all channel edges for the cache.
|
||||
@@ -904,6 +905,14 @@ func (c *VersionedGraph) HasChannelEdge(chanID uint64) (bool, bool, error) {
|
||||
return c.db.HasChannelEdge(c.v, chanID)
|
||||
}
|
||||
|
||||
// ForEachChannel iterates through all channel edges stored within the graph.
|
||||
func (c *VersionedGraph) ForEachChannel(ctx context.Context,
|
||||
cb func(*models.ChannelEdgeInfo, *models.ChannelEdgePolicy,
|
||||
*models.ChannelEdgePolicy) error, reset func()) error {
|
||||
|
||||
return c.db.ForEachChannel(ctx, c.v, cb, reset)
|
||||
}
|
||||
|
||||
// IsPublicNode determines whether the node is seen as public in the graph.
|
||||
func (c *VersionedGraph) IsPublicNode(pubKey [33]byte) (bool, error) {
|
||||
return c.db.IsPublicNode(c.v, pubKey)
|
||||
|
||||
Reference in new issue
Block a user