mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-28 06:32:18 +02:00
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:
26
graph/db/graph.go
Normal file
26
graph/db/graph.go
Normal 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
|
||||
}
|
Reference in New Issue
Block a user