From bb3839e422a43dde3f5736fb63593b5877dc296e Mon Sep 17 00:00:00 2001 From: Elle Mouton Date: Tue, 18 Feb 2025 15:06:33 -0300 Subject: [PATCH] graph/db: completely remove cache from KVStore --- graph/db/graph.go | 2 -- graph/db/graph_test.go | 1 - graph/db/kv_store.go | 12 +----------- 3 files changed, 1 insertion(+), 14 deletions(-) diff --git a/graph/db/graph.go b/graph/db/graph.go index ac80c259a..6e2132a5f 100644 --- a/graph/db/graph.go +++ b/graph/db/graph.go @@ -93,8 +93,6 @@ func NewChannelGraph(cfg *Config, options ...ChanGraphOption) (*ChannelGraph, log.Debugf("Finished populating in-memory channel graph (took %v, %s)", time.Since(startTime), graphCache.Stats()) - store.setGraphCache(graphCache) - return &ChannelGraph{ KVStore: store, graphCache: graphCache, diff --git a/graph/db/graph_test.go b/graph/db/graph_test.go index f336294a1..bc130c599 100644 --- a/graph/db/graph_test.go +++ b/graph/db/graph_test.go @@ -3994,7 +3994,6 @@ func TestGraphCacheForEachNodeChannel(t *testing.T) { // Unset the channel graph cache to simulate the user running with the // option turned off. graph.graphCache = nil - graph.KVStore.graphCache = nil node1, err := createTestVertex(graph.db) require.Nil(t, err) diff --git a/graph/db/kv_store.go b/graph/db/kv_store.go index d9786c2c6..0ea61a76c 100644 --- a/graph/db/kv_store.go +++ b/graph/db/kv_store.go @@ -184,13 +184,12 @@ const ( type KVStore struct { db kvdb.Backend - // cacheMu guards all caches (rejectCache, chanCache, graphCache). If + // cacheMu guards all caches (rejectCache and chanCache). If // this mutex will be acquired at the same time as the DB mutex then // the cacheMu MUST be acquired first to prevent deadlock. cacheMu sync.RWMutex rejectCache *rejectCache chanCache *channelCache - graphCache *GraphCache chanScheduler batch.Scheduler nodeScheduler batch.Scheduler @@ -227,15 +226,6 @@ func NewKVStore(db kvdb.Backend, options ...KVStoreOptionModifier) (*KVStore, return g, nil } -// setGraphCache sets the KVStore's graphCache. -// -// NOTE: this is temporary and will only be called from the ChannelGraph's -// constructor before the KVStore methods are available to be called. This will -// be removed once the graph cache is fully owned by the ChannelGraph. -func (c *KVStore) setGraphCache(cache *GraphCache) { - c.graphCache = cache -} - // channelMapKey is the key structure used for storing channel edge policies. type channelMapKey struct { nodeKey route.Vertex