mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-11-18 10:06:51 +01:00
This commit adds a new GraphSources interface that LND requires for graph related read-only queries. As of this commit, the interface is empty but it will be populated over the next couple of commits. We add an implementation of this interface backed by a pointer to a graphdb.ChannelGraph. The infrustructure is put into place so that the GraphSoure provided to LND can be overridden by a caller of the lnd.Main function. By default, LND will satisfy the interface itself via the new `graphsource.DBSource` struct.
22 lines
583 B
Go
22 lines
583 B
Go
package sources
|
|
|
|
import graphdb "github.com/lightningnetwork/lnd/graph/db"
|
|
|
|
// DBSource is an implementation of the GraphSource interface backed by a local
|
|
// persistence layer holding graph related data.
|
|
type DBSource struct {
|
|
db *graphdb.ChannelGraph
|
|
}
|
|
|
|
// A compile-time check to ensure that sources.DBSource implements the
|
|
// GraphSource interface.
|
|
var _ GraphSource = (*DBSource)(nil)
|
|
|
|
// NewDBGSource returns a new instance of the DBSource backed by a
|
|
// graphdb.ChannelGraph instance.
|
|
func NewDBGSource(db *graphdb.ChannelGraph) *DBSource {
|
|
return &DBSource{
|
|
db: db,
|
|
}
|
|
}
|