graph/db: define a NodeTraverser interface

Which describes methods that will use the graph cache if it is available
for fast read-only calls.
This commit is contained in:
Elle Mouton committed 2025-02-18 10:10:04 -03:00
1 parent 8ec08fbfa4
commit 99c9440520
2 files changed
+18

No files matched your search

+14
View File
@@ -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)
}