diff --git a/graph/db/graph.go b/graph/db/graph.go index cb8061b50..a5e79a688 100644 --- a/graph/db/graph.go +++ b/graph/db/graph.go @@ -185,7 +185,7 @@ func (c *ChannelGraph) populateCache(ctx context.Context) error { } err = c.db.ForEachChannelCacheable( - v, func(info *models.CachedEdgeInfo, + ctx, v, func(info *models.CachedEdgeInfo, policy1, policy2 *models.CachedEdgePolicy) error { @@ -950,11 +950,11 @@ func (c *VersionedGraph) ForEachNodeCacheable(ctx context.Context, } // ForEachChannelCacheable iterates through all channel edges for the cache. -func (c *VersionedGraph) ForEachChannelCacheable( +func (c *VersionedGraph) ForEachChannelCacheable(ctx context.Context, cb func(*models.CachedEdgeInfo, *models.CachedEdgePolicy, *models.CachedEdgePolicy) error, reset func()) error { - return c.db.ForEachChannelCacheable(c.v, cb, reset) + return c.db.ForEachChannelCacheable(ctx, c.v, cb, reset) } // DisabledChannelIDs returns the channel ids of disabled channels. diff --git a/graph/db/interfaces.go b/graph/db/interfaces.go index db0250760..f443953d1 100644 --- a/graph/db/interfaces.go +++ b/graph/db/interfaces.go @@ -185,7 +185,7 @@ type Store interface { //nolint:interfacebloat // // NOTE: this method is like ForEachChannel but fetches only the data // required for the graph cache. - ForEachChannelCacheable(v lnwire.GossipVersion, + ForEachChannelCacheable(ctx context.Context, v lnwire.GossipVersion, cb func(*models.CachedEdgeInfo, *models.CachedEdgePolicy, *models.CachedEdgePolicy) error, reset func()) error diff --git a/graph/db/kv_store.go b/graph/db/kv_store.go index ad330c8c3..94993c280 100644 --- a/graph/db/kv_store.go +++ b/graph/db/kv_store.go @@ -496,9 +496,10 @@ func forEachChannel(db kvdb.Backend, cb func(*models.ChannelEdgeInfo, // // NOTE: this method is like ForEachChannel but fetches only the data required // for the graph cache. -func (c *KVStore) ForEachChannelCacheable(v lnwire.GossipVersion, - cb func(*models.CachedEdgeInfo, *models.CachedEdgePolicy, - *models.CachedEdgePolicy) error, reset func()) error { +func (c *KVStore) ForEachChannelCacheable(_ context.Context, + v lnwire.GossipVersion, cb func(*models.CachedEdgeInfo, + *models.CachedEdgePolicy, *models.CachedEdgePolicy) error, + reset func()) error { if v != lnwire.GossipVersion1 { return ErrVersionNotSupportedForKVDB diff --git a/graph/db/sql_store.go b/graph/db/sql_store.go index fe8ca379c..745dff55a 100644 --- a/graph/db/sql_store.go +++ b/graph/db/sql_store.go @@ -1564,12 +1564,11 @@ func (s *SQLStore) ForEachNodeCached(ctx context.Context, withAddrs bool, // // NOTE: this method is like ForEachChannel but fetches only the data // required for the graph cache. -func (s *SQLStore) ForEachChannelCacheable(v lnwire.GossipVersion, +func (s *SQLStore) ForEachChannelCacheable(ctx context.Context, + v lnwire.GossipVersion, cb func(*models.CachedEdgeInfo, *models.CachedEdgePolicy, *models.CachedEdgePolicy) error, reset func()) error { - ctx := context.TODO() - if !isKnownGossipVersion(v) { return fmt.Errorf("unsupported gossip version: %d", v) }