graph/db: introduce ForEachChannelCacheable

Implement ForEachChannelCacheable which is like ForEachChannel but its
call-back takes the cached versions of channel info & policies. This is
then used during graph cache population. This will be useful once the
SQL implementation is added so that we can reduce the number of DB trips
on cache population.
This commit is contained in:
Elle Mouton committed 2025-06-10 20:10:36 +02:00
1 parent 3069a67b62
commit c52c6c962b
3 files changed
+90 -9

No files matched your search

+6 -9
View File
@@ -174,17 +174,14 @@ func (c *ChannelGraph) populateCache() error {
return err
}
err = c.V1Store.ForEachChannel(func(info *models.ChannelEdgeInfo,
policy1, policy2 *models.ChannelEdgePolicy) error {
err = c.V1Store.ForEachChannelCacheable(
func(info *models.CachedEdgeInfo,
policy1, policy2 *models.CachedEdgePolicy) error {
c.graphCache.AddChannel(
models.NewCachedEdge(info),
models.NewCachedPolicy(policy1),
models.NewCachedPolicy(policy2),
)
c.graphCache.AddChannel(info, policy1, policy2)
return nil
})
return nil
})
if err != nil {
return err
}