graph/db: thread context through ForEachChannelCacheable
This commit is contained in:
4 files changed
+10
-10
No files matched your search
+3
-3
@@ -185,7 +185,7 @@ func (c *ChannelGraph) populateCache(ctx context.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
err = c.db.ForEachChannelCacheable(
|
err = c.db.ForEachChannelCacheable(
|
||||||
v, func(info *models.CachedEdgeInfo,
|
ctx, v, func(info *models.CachedEdgeInfo,
|
||||||
policy1,
|
policy1,
|
||||||
policy2 *models.CachedEdgePolicy) error {
|
policy2 *models.CachedEdgePolicy) error {
|
||||||
|
|
||||||
@@ -950,11 +950,11 @@ func (c *VersionedGraph) ForEachNodeCacheable(ctx context.Context,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ForEachChannelCacheable iterates through all channel edges for the cache.
|
// 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,
|
cb func(*models.CachedEdgeInfo, *models.CachedEdgePolicy,
|
||||||
*models.CachedEdgePolicy) error, reset func()) error {
|
*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.
|
// DisabledChannelIDs returns the channel ids of disabled channels.
|
||||||
|
|||||||
@@ -185,7 +185,7 @@ type Store interface { //nolint:interfacebloat
|
|||||||
//
|
//
|
||||||
// NOTE: this method is like ForEachChannel but fetches only the data
|
// NOTE: this method is like ForEachChannel but fetches only the data
|
||||||
// required for the graph cache.
|
// required for the graph cache.
|
||||||
ForEachChannelCacheable(v lnwire.GossipVersion,
|
ForEachChannelCacheable(ctx context.Context, v lnwire.GossipVersion,
|
||||||
cb func(*models.CachedEdgeInfo, *models.CachedEdgePolicy,
|
cb func(*models.CachedEdgeInfo, *models.CachedEdgePolicy,
|
||||||
*models.CachedEdgePolicy) error, reset func()) error
|
*models.CachedEdgePolicy) error, reset func()) error
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
// NOTE: this method is like ForEachChannel but fetches only the data required
|
||||||
// for the graph cache.
|
// for the graph cache.
|
||||||
func (c *KVStore) ForEachChannelCacheable(v lnwire.GossipVersion,
|
func (c *KVStore) ForEachChannelCacheable(_ context.Context,
|
||||||
cb func(*models.CachedEdgeInfo, *models.CachedEdgePolicy,
|
v lnwire.GossipVersion, cb func(*models.CachedEdgeInfo,
|
||||||
*models.CachedEdgePolicy) error, reset func()) error {
|
*models.CachedEdgePolicy, *models.CachedEdgePolicy) error,
|
||||||
|
reset func()) error {
|
||||||
|
|
||||||
if v != lnwire.GossipVersion1 {
|
if v != lnwire.GossipVersion1 {
|
||||||
return ErrVersionNotSupportedForKVDB
|
return ErrVersionNotSupportedForKVDB
|
||||||
|
|||||||
@@ -1564,12 +1564,11 @@ func (s *SQLStore) ForEachNodeCached(ctx context.Context, withAddrs bool,
|
|||||||
//
|
//
|
||||||
// NOTE: this method is like ForEachChannel but fetches only the data
|
// NOTE: this method is like ForEachChannel but fetches only the data
|
||||||
// required for the graph cache.
|
// 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,
|
cb func(*models.CachedEdgeInfo, *models.CachedEdgePolicy,
|
||||||
*models.CachedEdgePolicy) error, reset func()) error {
|
*models.CachedEdgePolicy) error, reset func()) error {
|
||||||
|
|
||||||
ctx := context.TODO()
|
|
||||||
|
|
||||||
if !isKnownGossipVersion(v) {
|
if !isKnownGossipVersion(v) {
|
||||||
return fmt.Errorf("unsupported gossip version: %d", v)
|
return fmt.Errorf("unsupported gossip version: %d", v)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user