graph/db: let ForEachNodeCacheable take a context

This commit is contained in:
Elle Mouton committed 2025-07-08 15:10:30 +02:00
1 parent 85fda8b926
commit f05ef2db97
5 files changed
+11 -12

No files matched your search

+3 -3
View File
@@ -75,7 +75,7 @@ func (c *ChannelGraph) Start() error {
defer log.Debug("ChannelGraph started")
if c.graphCache != nil {
if err := c.populateCache(); err != nil {
if err := c.populateCache(context.TODO()); err != nil {
return fmt.Errorf("could not populate the graph "+
"cache: %w", err)
}
@@ -159,12 +159,12 @@ func (c *ChannelGraph) handleTopologySubscriptions() {
// populateCache loads the entire channel graph into the in-memory graph cache.
//
// NOTE: This should only be called if the graphCache has been constructed.
func (c *ChannelGraph) populateCache() error {
func (c *ChannelGraph) populateCache(ctx context.Context) error {
startTime := time.Now()
log.Info("Populating in-memory channel graph, this might take a " +
"while...")
err := c.V1Store.ForEachNodeCacheable(func(node route.Vertex,
err := c.V1Store.ForEachNodeCacheable(ctx, func(node route.Vertex,
features *lnwire.FeatureVector) error {
c.graphCache.AddNodeFeatures(node, features)