mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-07-01 11:00:51 +02:00
graph/db: completely remove cache from KVStore
This commit is contained in:
@ -93,8 +93,6 @@ func NewChannelGraph(cfg *Config, options ...ChanGraphOption) (*ChannelGraph,
|
|||||||
log.Debugf("Finished populating in-memory channel graph (took %v, %s)",
|
log.Debugf("Finished populating in-memory channel graph (took %v, %s)",
|
||||||
time.Since(startTime), graphCache.Stats())
|
time.Since(startTime), graphCache.Stats())
|
||||||
|
|
||||||
store.setGraphCache(graphCache)
|
|
||||||
|
|
||||||
return &ChannelGraph{
|
return &ChannelGraph{
|
||||||
KVStore: store,
|
KVStore: store,
|
||||||
graphCache: graphCache,
|
graphCache: graphCache,
|
||||||
|
@ -3994,7 +3994,6 @@ func TestGraphCacheForEachNodeChannel(t *testing.T) {
|
|||||||
// Unset the channel graph cache to simulate the user running with the
|
// Unset the channel graph cache to simulate the user running with the
|
||||||
// option turned off.
|
// option turned off.
|
||||||
graph.graphCache = nil
|
graph.graphCache = nil
|
||||||
graph.KVStore.graphCache = nil
|
|
||||||
|
|
||||||
node1, err := createTestVertex(graph.db)
|
node1, err := createTestVertex(graph.db)
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
|
@ -184,13 +184,12 @@ const (
|
|||||||
type KVStore struct {
|
type KVStore struct {
|
||||||
db kvdb.Backend
|
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
|
// this mutex will be acquired at the same time as the DB mutex then
|
||||||
// the cacheMu MUST be acquired first to prevent deadlock.
|
// the cacheMu MUST be acquired first to prevent deadlock.
|
||||||
cacheMu sync.RWMutex
|
cacheMu sync.RWMutex
|
||||||
rejectCache *rejectCache
|
rejectCache *rejectCache
|
||||||
chanCache *channelCache
|
chanCache *channelCache
|
||||||
graphCache *GraphCache
|
|
||||||
|
|
||||||
chanScheduler batch.Scheduler
|
chanScheduler batch.Scheduler
|
||||||
nodeScheduler batch.Scheduler
|
nodeScheduler batch.Scheduler
|
||||||
@ -227,15 +226,6 @@ func NewKVStore(db kvdb.Backend, options ...KVStoreOptionModifier) (*KVStore,
|
|||||||
return g, nil
|
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.
|
// channelMapKey is the key structure used for storing channel edge policies.
|
||||||
type channelMapKey struct {
|
type channelMapKey struct {
|
||||||
nodeKey route.Vertex
|
nodeKey route.Vertex
|
||||||
|
Reference in New Issue
Block a user