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:
3 files changed
+90
-9
No files matched your search
+6
-9
@@ -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
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user