graph/db: move gossip versions up one layer
Update some of the node related graph CRUD methods to take a version rather than hardcoding them in the SQLStore layer. Move the version up one layer instead. This will make it easier to make it configurable later on.
This commit is contained in:
5 files changed
+111
-53
No files matched your search
+19
-8
@@ -31,7 +31,14 @@ type NodeTraverser interface {
|
||||
// Store 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 Store interface { //nolint:interfacebloat
|
||||
NodeTraverser
|
||||
// ForEachNodeDirectedChannel calls the callback for every channel of
|
||||
// the given node.
|
||||
ForEachNodeDirectedChannel(nodePub route.Vertex,
|
||||
cb func(channel *DirectedChannel) error, reset func()) error
|
||||
|
||||
// FetchNodeFeatures returns the features of the given node.
|
||||
FetchNodeFeatures(v lnwire.GossipVersion,
|
||||
nodePub route.Vertex) (*lnwire.FeatureVector, error)
|
||||
|
||||
// AddNode adds a vertex/node to the graph database. If the
|
||||
// node is not in the database from before, this will add a new,
|
||||
@@ -45,7 +52,7 @@ type Store interface { //nolint:interfacebloat
|
||||
// AddrsForNode returns all known addresses for the target node public
|
||||
// key that the graph DB is aware of. The returned boolean indicates if
|
||||
// the given node is unknown to the graph DB or not.
|
||||
AddrsForNode(ctx context.Context,
|
||||
AddrsForNode(ctx context.Context, v lnwire.GossipVersion,
|
||||
nodePub *btcec.PublicKey) (bool, []net.Addr, error)
|
||||
|
||||
// ForEachSourceNodeChannel iterates through all channels of the source
|
||||
@@ -100,11 +107,13 @@ type Store interface { //nolint:interfacebloat
|
||||
|
||||
// LookupAlias attempts to return the alias as advertised by the target
|
||||
// node.
|
||||
LookupAlias(ctx context.Context, pub *btcec.PublicKey) (string, error)
|
||||
LookupAlias(ctx context.Context, v lnwire.GossipVersion,
|
||||
pub *btcec.PublicKey) (string, error)
|
||||
|
||||
// DeleteNode starts a new database transaction to remove a
|
||||
// vertex/node from the database according to the node's public key.
|
||||
DeleteNode(ctx context.Context, nodePub route.Vertex) error
|
||||
DeleteNode(ctx context.Context, v lnwire.GossipVersion,
|
||||
nodePub route.Vertex) error
|
||||
|
||||
// NodeUpdatesInHorizon returns all the known lightning node which have
|
||||
// an update timestamp within the passed range. This method can be used
|
||||
@@ -116,8 +125,8 @@ type Store interface { //nolint:interfacebloat
|
||||
// FetchNode attempts to look up a target node by its identity
|
||||
// public key. If the node isn't found in the database, then
|
||||
// ErrGraphNodeNotFound is returned.
|
||||
FetchNode(ctx context.Context, nodePub route.Vertex) (*models.Node,
|
||||
error)
|
||||
FetchNode(ctx context.Context, v lnwire.GossipVersion,
|
||||
nodePub route.Vertex) (*models.Node, error)
|
||||
|
||||
// HasV1Node determines if the graph has a vertex identified by
|
||||
// the target node identity public key in the V1 graph. If the node
|
||||
@@ -131,7 +140,8 @@ type Store interface { //nolint:interfacebloat
|
||||
|
||||
// HasNode determines if the graph has a vertex identified by
|
||||
// the target node identity public key.
|
||||
HasNode(ctx context.Context, nodePub [33]byte) (bool, error)
|
||||
HasNode(ctx context.Context, v lnwire.GossipVersion,
|
||||
nodePub [33]byte) (bool, error)
|
||||
|
||||
// IsPublicNode is a helper method that determines whether the node with
|
||||
// the given public key is seen as a public node in the graph from the
|
||||
@@ -334,7 +344,8 @@ type Store interface { //nolint:interfacebloat
|
||||
// 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)
|
||||
SourceNode(ctx context.Context, v lnwire.GossipVersion) (*models.Node,
|
||||
error)
|
||||
|
||||
// SetSourceNode sets the source node within the graph database. The
|
||||
// source node is to be used as the center of a star-graph within path
|
||||
|
||||
Reference in new issue
Block a user