graph/db: rename ChannelGraph and introduce the new ChannelGraph layer

In this commit, we rename the existing ChannelGraph struct to KVStore to
better reflect its responsibilities as the CRUD layer. We then introduce
a new ChannelGraph struct which will eventually be the layer above the
CRUD layer in which we will handle cacheing and topology subscriptions.
For now, however, it houses only the KVStore. This means that all calls
to the KVStore will now go through this layer of indirection first. This
will allow us to slowly move the graph Cache management out of the
KVStore and into the new ChannelGraph layer.

We introduce the new ChannelGraph and rename the old one in the same
commit so that all existing call-sites don't need to change at all :)
This commit is contained in:
Elle Mouton
2025-02-18 13:19:50 -03:00
parent ed8e10e4b9
commit 1ee4bb8c51
2 changed files with 101 additions and 75 deletions

26
graph/db/graph.go Normal file
View File

@@ -0,0 +1,26 @@
package graphdb
import "github.com/lightningnetwork/lnd/kvdb"
// ChannelGraph is a layer above the graph's CRUD layer.
//
// NOTE: currently, this is purely a pass-through layer directly to the backing
// KVStore. Upcoming commits will move the graph cache out of the KVStore and
// into this layer so that the KVStore is only responsible for CRUD operations.
type ChannelGraph struct {
*KVStore
}
// NewChannelGraph creates a new ChannelGraph instance with the given backend.
func NewChannelGraph(db kvdb.Backend, options ...OptionModifier) (*ChannelGraph,
error) {
store, err := NewKVStore(db, options...)
if err != nil {
return nil, err
}
return &ChannelGraph{
KVStore: store,
}, nil
}