diff --git a/graph/db/graph.go b/graph/db/graph.go index cb53ae547..ad9ad2ad4 100644 --- a/graph/db/graph.go +++ b/graph/db/graph.go @@ -602,6 +602,8 @@ func (c *ChannelGraph) FetchNodeFeaturesTx(tx kvdb.RTx, // of the database. // // Unknown policies are passed into the callback as nil values. +// +// NOTE: this is part of the graphdb.NodeTraverser interface. func (c *ChannelGraph) ForEachNodeDirectedChannel(nodePub route.Vertex, cb func(channel *DirectedChannel) error) error { @@ -612,6 +614,8 @@ func (c *ChannelGraph) ForEachNodeDirectedChannel(nodePub route.Vertex, // known for the node, an empty feature vector is returned. // If the graphCache is available, then it will be used to retrieve the node's // features instead of the database. +// +// NOTE: this is part of the graphdb.NodeTraverser interface. func (c *ChannelGraph) FetchNodeFeatures(nodePub route.Vertex) ( *lnwire.FeatureVector, error) { diff --git a/graph/db/interfaces.go b/graph/db/interfaces.go index f44a9ff8b..f5dce71ca 100644 --- a/graph/db/interfaces.go +++ b/graph/db/interfaces.go @@ -2,6 +2,7 @@ package graphdb import ( "github.com/lightningnetwork/lnd/graph/db/models" + "github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/routing/route" ) @@ -23,3 +24,16 @@ type NodeRTx interface { // the same transaction. FetchNode(node route.Vertex) (NodeRTx, error) } + +// NodeTraverser is an abstract read only interface that provides information +// about nodes and their edges. The interface is about providing fast read-only +// access to the graph and so if a cache is available, it should be used. +type NodeTraverser interface { + // ForEachNodeDirectedChannel calls the callback for every channel of + // the given node. + ForEachNodeDirectedChannel(nodePub route.Vertex, + cb func(channel *DirectedChannel) error) error + + // FetchNodeFeatures returns the features of the given node. + FetchNodeFeatures(nodePub route.Vertex) (*lnwire.FeatureVector, error) +}