refactor: move graph related DB code to graph/db from channeldb

This is a pure refactor commit. It moves over all the graph related CRUD
code from `channeldb` to `graph/db`.
This commit is contained in:
Elle Mouton
2024-10-22 13:35:23 +02:00
parent 9f54ec90aa
commit 74a4b1922b
57 changed files with 512 additions and 299 deletions

View File

@@ -336,7 +336,7 @@ type DB struct {
channelStateDB *ChannelStateDB
dbPath string
graph *ChannelGraph
graph *graphdb.ChannelGraph
clock clock.Clock
dryRun bool
keepFailedPaymentAttempts bool
@@ -410,7 +410,7 @@ func CreateWithBackend(backend kvdb.Backend,
chanDB.channelStateDB.parent = chanDB
var err error
chanDB.graph, err = NewChannelGraph(
chanDB.graph, err = graphdb.NewChannelGraph(
backend, opts.RejectCacheSize, opts.ChannelCacheSize,
opts.BatchCommitInterval, opts.PreAllocCacheNumNodes,
opts.UseGraphCache, opts.NoMigration,
@@ -1370,12 +1370,12 @@ func (d *DB) AddrsForNode(nodePub *btcec.PublicKey) ([]net.Addr,
return nil, err
}
graphNode, err := d.graph.FetchLightningNode(pubKey)
if err != nil && err != ErrGraphNodeNotFound {
if err != nil && err != graphdb.ErrGraphNodeNotFound {
return nil, err
} else if err == ErrGraphNodeNotFound {
} else if err == graphdb.ErrGraphNodeNotFound {
// If the node isn't found, then that's OK, as we still have the
// link node data. But any other error needs to be returned.
graphNode = &LightningNode{}
graphNode = &graphdb.LightningNode{}
}
// Now that we have both sources of addrs for this node, we'll use a
@@ -1647,7 +1647,7 @@ func (d *DB) applyOptionalVersions(cfg OptionalMiragtionConfig) error {
}
// ChannelGraph returns the current instance of the directed channel graph.
func (d *DB) ChannelGraph() *ChannelGraph {
func (d *DB) ChannelGraph() *graphdb.ChannelGraph {
return d.graph
}