mirror of
https://github.com/lightningnetwork/lnd.git
synced 2026-08-15 12:50:15 +02:00
Copy over all the code that the graph SQL migration needs to a separate folder. This will let us advance the main graph SQL CRUD code without worrying about changing the sql migration code. It will also let us change the SQL queries without changing the migration. In this commit, only the migration logic is "frozen" but in an upcoming commit, the sqlc queries & models will be frozen too.
37 lines
1.6 KiB
Go
37 lines
1.6 KiB
Go
package migration1
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/lightningnetwork/lnd/graph/db/migration1/models"
|
|
)
|
|
|
|
// V1Store represents the main interface for the channel graph database for all
|
|
// channels and nodes gossiped via the V1 gossip protocol as defined in BOLT 7.
|
|
type V1Store interface {
|
|
// ForEachNode iterates through all the stored vertices/nodes in the
|
|
// graph, executing the passed callback with each node encountered. If
|
|
// the callback returns an error, then the transaction is aborted and
|
|
// the iteration stops early.
|
|
ForEachNode(ctx context.Context, cb func(*models.Node) error,
|
|
reset func()) error
|
|
|
|
// ForEachChannel iterates through all the channel edges stored within
|
|
// the graph and invokes the passed callback for each edge. The callback
|
|
// takes two edges as since this is a directed graph, both the in/out
|
|
// edges are visited. If the callback returns an error, then the
|
|
// transaction is aborted and the iteration stops early.
|
|
//
|
|
// NOTE: If an edge can't be found, or wasn't advertised, then a nil
|
|
// pointer for that particular channel edge routing policy will be
|
|
// passed into the callback.
|
|
ForEachChannel(ctx context.Context, cb func(*models.ChannelEdgeInfo,
|
|
*models.ChannelEdgePolicy, *models.ChannelEdgePolicy) error,
|
|
reset func()) error
|
|
|
|
// SourceNode returns the source node of the graph. The source node is
|
|
// treated as the center node within a star-graph. This method may be
|
|
// used to kick off a path finding algorithm in order to explore the
|
|
// reachability of another node based off the source node.
|
|
SourceNode(ctx context.Context) (*models.Node, error)
|
|
}
|