graph/db: rename V1Store to Store
The underling store will store gossip messages across gossip versions and we will instead expose version parameters on many of the methods. So this interface really just abstracts the underlying store/schema type.
This commit is contained in:
11 files changed
+111
-111
No files matched your search
+1
-1
@@ -1096,7 +1096,7 @@ func (d *DefaultDatabaseBuilder) BuildDatabase(
|
|||||||
|
|
||||||
// The graph store implementation we will use depends on whether
|
// The graph store implementation we will use depends on whether
|
||||||
// native SQL is enabled or not.
|
// native SQL is enabled or not.
|
||||||
var graphStore graphdb.V1Store
|
var graphStore graphdb.Store
|
||||||
|
|
||||||
// Instantiate a native SQL store if the flag is set.
|
// Instantiate a native SQL store if the flag is set.
|
||||||
if d.cfg.DB.UseNativeSQL {
|
if d.cfg.DB.UseNativeSQL {
|
||||||
|
|||||||
+26
-26
@@ -72,19 +72,19 @@ var (
|
|||||||
// and a function to open the connection.
|
// and a function to open the connection.
|
||||||
type dbConnection struct {
|
type dbConnection struct {
|
||||||
name string
|
name string
|
||||||
open func(testing.TB) V1Store
|
open func(testing.TB) Store
|
||||||
}
|
}
|
||||||
|
|
||||||
// This var block defines the various database connections that we will use
|
// This var block defines the various database connections that we will use
|
||||||
// for testing. Each connection is defined as a dbConnection struct that
|
// for testing. Each connection is defined as a dbConnection struct that
|
||||||
// contains a name and an open function. The open function is used to create
|
// contains a name and an open function. The open function is used to create
|
||||||
// a new V1Store instance for the given database type.
|
// a new Store instance for the given database type.
|
||||||
var (
|
var (
|
||||||
// kvdbBBoltConn is a connection to a kvdb-bbolt database called
|
// kvdbBBoltConn is a connection to a kvdb-bbolt database called
|
||||||
// channel.db.
|
// channel.db.
|
||||||
kvdbBBoltConn = dbConnection{
|
kvdbBBoltConn = dbConnection{
|
||||||
name: "kvdb-bbolt",
|
name: "kvdb-bbolt",
|
||||||
open: func(b testing.TB) V1Store {
|
open: func(b testing.TB) Store {
|
||||||
return connectBBoltDB(b, bboltDBPath, kvdbBBoltFile)
|
return connectBBoltDB(b, bboltDBPath, kvdbBBoltFile)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -93,7 +93,7 @@ var (
|
|||||||
// channel.sqlite.
|
// channel.sqlite.
|
||||||
kvdbSqliteConn = dbConnection{
|
kvdbSqliteConn = dbConnection{
|
||||||
name: "kvdb-sqlite",
|
name: "kvdb-sqlite",
|
||||||
open: func(b testing.TB) V1Store {
|
open: func(b testing.TB) Store {
|
||||||
return connectKVDBSqlite(
|
return connectKVDBSqlite(
|
||||||
b, kvdbSqlitePath, kvdbSqliteFile,
|
b, kvdbSqlitePath, kvdbSqliteFile,
|
||||||
)
|
)
|
||||||
@@ -104,7 +104,7 @@ var (
|
|||||||
// called lnd.sqlite.
|
// called lnd.sqlite.
|
||||||
nativeSQLSqliteConn = dbConnection{
|
nativeSQLSqliteConn = dbConnection{
|
||||||
name: "native-sqlite",
|
name: "native-sqlite",
|
||||||
open: func(b testing.TB) V1Store {
|
open: func(b testing.TB) Store {
|
||||||
return connectNativeSQLite(
|
return connectNativeSQLite(
|
||||||
b, sqldb.DefaultSQLiteConfig(),
|
b, sqldb.DefaultSQLiteConfig(),
|
||||||
nativeSQLSqlitePath, nativeSQLSqliteFile,
|
nativeSQLSqlitePath, nativeSQLSqliteFile,
|
||||||
@@ -116,7 +116,7 @@ var (
|
|||||||
// using a postgres connection string.
|
// using a postgres connection string.
|
||||||
kvdbPostgresConn = dbConnection{
|
kvdbPostgresConn = dbConnection{
|
||||||
name: "kvdb-postgres",
|
name: "kvdb-postgres",
|
||||||
open: func(b testing.TB) V1Store {
|
open: func(b testing.TB) Store {
|
||||||
return connectKVDBPostgres(b, kvdbPostgresDNS)
|
return connectKVDBPostgres(b, kvdbPostgresDNS)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -125,7 +125,7 @@ var (
|
|||||||
// database using a postgres connection string.
|
// database using a postgres connection string.
|
||||||
nativeSQLPostgresConn = dbConnection{
|
nativeSQLPostgresConn = dbConnection{
|
||||||
name: "native-postgres",
|
name: "native-postgres",
|
||||||
open: func(b testing.TB) V1Store {
|
open: func(b testing.TB) Store {
|
||||||
return connectNativePostgres(
|
return connectNativePostgres(
|
||||||
b, sqldb.DefaultPostgresConfig(),
|
b, sqldb.DefaultPostgresConfig(),
|
||||||
nativeSQLPostgresDNS,
|
nativeSQLPostgresDNS,
|
||||||
@@ -134,10 +134,10 @@ var (
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
// connectNativePostgres creates a V1Store instance backed by a native Postgres
|
// connectNativePostgres creates a Store instance backed by a native Postgres
|
||||||
// database for testing purposes.
|
// database for testing purposes.
|
||||||
func connectNativePostgres(t testing.TB, cfg *sqldb.QueryConfig,
|
func connectNativePostgres(t testing.TB, cfg *sqldb.QueryConfig,
|
||||||
dsn string) V1Store {
|
dsn string) Store {
|
||||||
|
|
||||||
return newSQLStore(t, cfg, sqlPostgres(t, dsn))
|
return newSQLStore(t, cfg, sqlPostgres(t, dsn))
|
||||||
}
|
}
|
||||||
@@ -157,10 +157,10 @@ func sqlPostgres(t testing.TB, dsn string) BatchedSQLQueries {
|
|||||||
return newSQLExecutor(t, store)
|
return newSQLExecutor(t, store)
|
||||||
}
|
}
|
||||||
|
|
||||||
// connectNativeSQLite creates a V1Store instance backed by a native SQLite
|
// connectNativeSQLite creates a Store instance backed by a native SQLite
|
||||||
// database for testing purposes.
|
// database for testing purposes.
|
||||||
func connectNativeSQLite(t testing.TB, cfg *sqldb.QueryConfig, dbPath,
|
func connectNativeSQLite(t testing.TB, cfg *sqldb.QueryConfig, dbPath,
|
||||||
file string) V1Store {
|
file string) Store {
|
||||||
|
|
||||||
return newSQLStore(t, cfg, sqlSQLite(t, dbPath, file))
|
return newSQLStore(t, cfg, sqlSQLite(t, dbPath, file))
|
||||||
}
|
}
|
||||||
@@ -205,9 +205,9 @@ func kvdbPostgres(t testing.TB, dsn string) kvdb.Backend {
|
|||||||
return kvStore
|
return kvStore
|
||||||
}
|
}
|
||||||
|
|
||||||
// connectKVDBPostgres creates a V1Store instance backed by a kvdb-postgres
|
// connectKVDBPostgres creates a Store instance backed by a kvdb-postgres
|
||||||
// database for testing purposes.
|
// database for testing purposes.
|
||||||
func connectKVDBPostgres(t testing.TB, dsn string) V1Store {
|
func connectKVDBPostgres(t testing.TB, dsn string) Store {
|
||||||
return newKVStore(t, kvdbPostgres(t, dsn))
|
return newKVStore(t, kvdbPostgres(t, dsn))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -231,14 +231,14 @@ func kvdbSqlite(t testing.TB, dbPath, fileName string) kvdb.Backend {
|
|||||||
return kvStore
|
return kvStore
|
||||||
}
|
}
|
||||||
|
|
||||||
// connectKVDBSqlite creates a V1Store instance backed by a kvdb-sqlite
|
// connectKVDBSqlite creates a Store instance backed by a kvdb-sqlite
|
||||||
// database for testing purposes.
|
// database for testing purposes.
|
||||||
func connectKVDBSqlite(t testing.TB, dbPath, fileName string) V1Store {
|
func connectKVDBSqlite(t testing.TB, dbPath, fileName string) Store {
|
||||||
return newKVStore(t, kvdbSqlite(t, dbPath, fileName))
|
return newKVStore(t, kvdbSqlite(t, dbPath, fileName))
|
||||||
}
|
}
|
||||||
|
|
||||||
// connectBBoltDB creates a new BBolt database connection for testing.
|
// connectBBoltDB creates a new BBolt database connection for testing.
|
||||||
func connectBBoltDB(t testing.TB, dbPath, fileName string) V1Store {
|
func connectBBoltDB(t testing.TB, dbPath, fileName string) Store {
|
||||||
return newKVStore(t, kvdbBBolt(t, dbPath, fileName))
|
return newKVStore(t, kvdbBBolt(t, dbPath, fileName))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -261,7 +261,7 @@ func kvdbBBolt(t testing.TB, dbPath, fileName string) kvdb.Backend {
|
|||||||
|
|
||||||
// newKVStore creates a new KVStore instance for testing using a provided
|
// newKVStore creates a new KVStore instance for testing using a provided
|
||||||
// kvdb.Backend instance.
|
// kvdb.Backend instance.
|
||||||
func newKVStore(t testing.TB, backend kvdb.Backend) V1Store {
|
func newKVStore(t testing.TB, backend kvdb.Backend) Store {
|
||||||
store, err := NewKVStore(backend, testStoreOptions...)
|
store, err := NewKVStore(backend, testStoreOptions...)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
@@ -286,7 +286,7 @@ func newSQLExecutor(t testing.TB, db sqldb.DB) BatchedSQLQueries {
|
|||||||
// newSQLStore creates a new SQLStore instance for testing using a provided
|
// newSQLStore creates a new SQLStore instance for testing using a provided
|
||||||
// sqldb.DB instance.
|
// sqldb.DB instance.
|
||||||
func newSQLStore(t testing.TB, cfg *sqldb.QueryConfig,
|
func newSQLStore(t testing.TB, cfg *sqldb.QueryConfig,
|
||||||
db BatchedSQLQueries) V1Store {
|
db BatchedSQLQueries) Store {
|
||||||
|
|
||||||
store, err := NewSQLStore(
|
store, err := NewSQLStore(
|
||||||
&SQLStoreConfig{
|
&SQLStoreConfig{
|
||||||
@@ -587,7 +587,7 @@ func BenchmarkCacheLoading(b *testing.B) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// BenchmarkGraphReadMethods benchmarks various read calls of various V1Store
|
// BenchmarkGraphReadMethods benchmarks various read calls of various Store
|
||||||
// implementations.
|
// implementations.
|
||||||
//
|
//
|
||||||
// NOTE: this is to be run against a local graph database. It can be run
|
// NOTE: this is to be run against a local graph database. It can be run
|
||||||
@@ -614,11 +614,11 @@ func BenchmarkGraphReadMethods(b *testing.B) {
|
|||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
fn func(b testing.TB, store V1Store)
|
fn func(b testing.TB, store Store)
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "ForEachNode",
|
name: "ForEachNode",
|
||||||
fn: func(b testing.TB, store V1Store) {
|
fn: func(b testing.TB, store Store) {
|
||||||
err := store.ForEachNode(
|
err := store.ForEachNode(
|
||||||
ctx,
|
ctx,
|
||||||
func(_ *models.Node) error {
|
func(_ *models.Node) error {
|
||||||
@@ -635,7 +635,7 @@ func BenchmarkGraphReadMethods(b *testing.B) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "ForEachChannel",
|
name: "ForEachChannel",
|
||||||
fn: func(b testing.TB, store V1Store) {
|
fn: func(b testing.TB, store Store) {
|
||||||
//nolint:ll
|
//nolint:ll
|
||||||
err := store.ForEachChannel(
|
err := store.ForEachChannel(
|
||||||
ctx, func(_ *models.ChannelEdgeInfo,
|
ctx, func(_ *models.ChannelEdgeInfo,
|
||||||
@@ -655,7 +655,7 @@ func BenchmarkGraphReadMethods(b *testing.B) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "NodeUpdatesInHorizon",
|
name: "NodeUpdatesInHorizon",
|
||||||
fn: func(b testing.TB, store V1Store) {
|
fn: func(b testing.TB, store Store) {
|
||||||
iter := store.NodeUpdatesInHorizon(
|
iter := store.NodeUpdatesInHorizon(
|
||||||
time.Unix(0, 0), time.Now(),
|
time.Unix(0, 0), time.Now(),
|
||||||
)
|
)
|
||||||
@@ -665,7 +665,7 @@ func BenchmarkGraphReadMethods(b *testing.B) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "ForEachNodeCacheable",
|
name: "ForEachNodeCacheable",
|
||||||
fn: func(b testing.TB, store V1Store) {
|
fn: func(b testing.TB, store Store) {
|
||||||
err := store.ForEachNodeCacheable(
|
err := store.ForEachNodeCacheable(
|
||||||
ctx, func(_ route.Vertex,
|
ctx, func(_ route.Vertex,
|
||||||
_ *lnwire.FeatureVector) error {
|
_ *lnwire.FeatureVector) error {
|
||||||
@@ -683,7 +683,7 @@ func BenchmarkGraphReadMethods(b *testing.B) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "ForEachNodeCached",
|
name: "ForEachNodeCached",
|
||||||
fn: func(b testing.TB, store V1Store) {
|
fn: func(b testing.TB, store Store) {
|
||||||
//nolint:ll
|
//nolint:ll
|
||||||
err := store.ForEachNodeCached(
|
err := store.ForEachNodeCached(
|
||||||
ctx, false, func(context.Context,
|
ctx, false, func(context.Context,
|
||||||
@@ -704,7 +704,7 @@ func BenchmarkGraphReadMethods(b *testing.B) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "ChanUpdatesInHorizon",
|
name: "ChanUpdatesInHorizon",
|
||||||
fn: func(b testing.TB, store V1Store) {
|
fn: func(b testing.TB, store Store) {
|
||||||
iter := store.ChanUpdatesInHorizon(
|
iter := store.ChanUpdatesInHorizon(
|
||||||
time.Unix(0, 0), time.Now(),
|
time.Unix(0, 0), time.Now(),
|
||||||
)
|
)
|
||||||
|
|||||||
+24
-24
@@ -30,7 +30,7 @@ type ChannelGraph struct {
|
|||||||
|
|
||||||
graphCache *GraphCache
|
graphCache *GraphCache
|
||||||
|
|
||||||
V1Store
|
Store
|
||||||
*topologyManager
|
*topologyManager
|
||||||
|
|
||||||
quit chan struct{}
|
quit chan struct{}
|
||||||
@@ -38,7 +38,7 @@ type ChannelGraph struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewChannelGraph creates a new ChannelGraph instance with the given backend.
|
// NewChannelGraph creates a new ChannelGraph instance with the given backend.
|
||||||
func NewChannelGraph(v1Store V1Store,
|
func NewChannelGraph(v1Store Store,
|
||||||
options ...ChanGraphOption) (*ChannelGraph, error) {
|
options ...ChanGraphOption) (*ChannelGraph, error) {
|
||||||
|
|
||||||
opts := defaultChanGraphOptions()
|
opts := defaultChanGraphOptions()
|
||||||
@@ -47,7 +47,7 @@ func NewChannelGraph(v1Store V1Store,
|
|||||||
}
|
}
|
||||||
|
|
||||||
g := &ChannelGraph{
|
g := &ChannelGraph{
|
||||||
V1Store: v1Store,
|
Store: v1Store,
|
||||||
topologyManager: newTopologyManager(),
|
topologyManager: newTopologyManager(),
|
||||||
quit: make(chan struct{}),
|
quit: make(chan struct{}),
|
||||||
}
|
}
|
||||||
@@ -161,7 +161,7 @@ func (c *ChannelGraph) populateCache(ctx context.Context) error {
|
|||||||
log.Info("Populating in-memory channel graph, this might take a " +
|
log.Info("Populating in-memory channel graph, this might take a " +
|
||||||
"while...")
|
"while...")
|
||||||
|
|
||||||
err := c.V1Store.ForEachNodeCacheable(ctx, func(node route.Vertex,
|
err := c.Store.ForEachNodeCacheable(ctx, func(node route.Vertex,
|
||||||
features *lnwire.FeatureVector) error {
|
features *lnwire.FeatureVector) error {
|
||||||
|
|
||||||
c.graphCache.AddNodeFeatures(node, features)
|
c.graphCache.AddNodeFeatures(node, features)
|
||||||
@@ -172,7 +172,7 @@ func (c *ChannelGraph) populateCache(ctx context.Context) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = c.V1Store.ForEachChannelCacheable(
|
err = c.Store.ForEachChannelCacheable(
|
||||||
func(info *models.CachedEdgeInfo,
|
func(info *models.CachedEdgeInfo,
|
||||||
policy1, policy2 *models.CachedEdgePolicy) error {
|
policy1, policy2 *models.CachedEdgePolicy) error {
|
||||||
|
|
||||||
@@ -208,7 +208,7 @@ func (c *ChannelGraph) ForEachNodeDirectedChannel(node route.Vertex,
|
|||||||
return c.graphCache.ForEachChannel(node, cb)
|
return c.graphCache.ForEachChannel(node, cb)
|
||||||
}
|
}
|
||||||
|
|
||||||
return c.V1Store.ForEachNodeDirectedChannel(node, cb, reset)
|
return c.Store.ForEachNodeDirectedChannel(node, cb, reset)
|
||||||
}
|
}
|
||||||
|
|
||||||
// FetchNodeFeatures returns the features of the given node. If no features are
|
// FetchNodeFeatures returns the features of the given node. If no features are
|
||||||
@@ -224,7 +224,7 @@ func (c *ChannelGraph) FetchNodeFeatures(node route.Vertex) (
|
|||||||
return c.graphCache.GetFeatures(node), nil
|
return c.graphCache.GetFeatures(node), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return c.V1Store.FetchNodeFeatures(node)
|
return c.Store.FetchNodeFeatures(node)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GraphSession will provide the call-back with access to a NodeTraverser
|
// GraphSession will provide the call-back with access to a NodeTraverser
|
||||||
@@ -238,7 +238,7 @@ func (c *ChannelGraph) GraphSession(cb func(graph NodeTraverser) error,
|
|||||||
return cb(c)
|
return cb(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
return c.V1Store.GraphSession(cb, reset)
|
return c.Store.GraphSession(cb, reset)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ForEachNodeCached iterates through all the stored vertices/nodes in the
|
// ForEachNodeCached iterates through all the stored vertices/nodes in the
|
||||||
@@ -259,7 +259,7 @@ func (c *ChannelGraph) ForEachNodeCached(ctx context.Context, withAddrs bool,
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return c.V1Store.ForEachNodeCached(ctx, withAddrs, cb, reset)
|
return c.Store.ForEachNodeCached(ctx, withAddrs, cb, reset)
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddNode adds a vertex/node to the graph database. If the node is not
|
// AddNode adds a vertex/node to the graph database. If the node is not
|
||||||
@@ -271,7 +271,7 @@ func (c *ChannelGraph) ForEachNodeCached(ctx context.Context, withAddrs bool,
|
|||||||
func (c *ChannelGraph) AddNode(ctx context.Context,
|
func (c *ChannelGraph) AddNode(ctx context.Context,
|
||||||
node *models.Node, op ...batch.SchedulerOption) error {
|
node *models.Node, op ...batch.SchedulerOption) error {
|
||||||
|
|
||||||
err := c.V1Store.AddNode(ctx, node, op...)
|
err := c.Store.AddNode(ctx, node, op...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -296,7 +296,7 @@ func (c *ChannelGraph) AddNode(ctx context.Context,
|
|||||||
func (c *ChannelGraph) DeleteNode(ctx context.Context,
|
func (c *ChannelGraph) DeleteNode(ctx context.Context,
|
||||||
nodePub route.Vertex) error {
|
nodePub route.Vertex) error {
|
||||||
|
|
||||||
err := c.V1Store.DeleteNode(ctx, nodePub)
|
err := c.Store.DeleteNode(ctx, nodePub)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -317,7 +317,7 @@ func (c *ChannelGraph) DeleteNode(ctx context.Context,
|
|||||||
func (c *ChannelGraph) AddChannelEdge(ctx context.Context,
|
func (c *ChannelGraph) AddChannelEdge(ctx context.Context,
|
||||||
edge *models.ChannelEdgeInfo, op ...batch.SchedulerOption) error {
|
edge *models.ChannelEdgeInfo, op ...batch.SchedulerOption) error {
|
||||||
|
|
||||||
err := c.V1Store.AddChannelEdge(ctx, edge, op...)
|
err := c.Store.AddChannelEdge(ctx, edge, op...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -339,7 +339,7 @@ func (c *ChannelGraph) AddChannelEdge(ctx context.Context,
|
|||||||
// If the cache is enabled, the edge will be added back to the graph cache if
|
// If the cache is enabled, the edge will be added back to the graph cache if
|
||||||
// we still have a record of this channel in the DB.
|
// we still have a record of this channel in the DB.
|
||||||
func (c *ChannelGraph) MarkEdgeLive(chanID uint64) error {
|
func (c *ChannelGraph) MarkEdgeLive(chanID uint64) error {
|
||||||
err := c.V1Store.MarkEdgeLive(chanID)
|
err := c.Store.MarkEdgeLive(chanID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -347,7 +347,7 @@ func (c *ChannelGraph) MarkEdgeLive(chanID uint64) error {
|
|||||||
if c.graphCache != nil {
|
if c.graphCache != nil {
|
||||||
// We need to add the channel back into our graph cache,
|
// We need to add the channel back into our graph cache,
|
||||||
// otherwise we won't use it for path finding.
|
// otherwise we won't use it for path finding.
|
||||||
infos, err := c.V1Store.FetchChanInfos([]uint64{chanID})
|
infos, err := c.Store.FetchChanInfos([]uint64{chanID})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -385,7 +385,7 @@ func (c *ChannelGraph) MarkEdgeLive(chanID uint64) error {
|
|||||||
func (c *ChannelGraph) DeleteChannelEdges(strictZombiePruning, markZombie bool,
|
func (c *ChannelGraph) DeleteChannelEdges(strictZombiePruning, markZombie bool,
|
||||||
chanIDs ...uint64) error {
|
chanIDs ...uint64) error {
|
||||||
|
|
||||||
infos, err := c.V1Store.DeleteChannelEdges(
|
infos, err := c.Store.DeleteChannelEdges(
|
||||||
strictZombiePruning, markZombie, chanIDs...,
|
strictZombiePruning, markZombie, chanIDs...,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -414,7 +414,7 @@ func (c *ChannelGraph) DeleteChannelEdges(strictZombiePruning, markZombie bool,
|
|||||||
func (c *ChannelGraph) DisconnectBlockAtHeight(height uint32) (
|
func (c *ChannelGraph) DisconnectBlockAtHeight(height uint32) (
|
||||||
[]*models.ChannelEdgeInfo, error) {
|
[]*models.ChannelEdgeInfo, error) {
|
||||||
|
|
||||||
edges, err := c.V1Store.DisconnectBlockAtHeight(height)
|
edges, err := c.Store.DisconnectBlockAtHeight(height)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -442,7 +442,7 @@ func (c *ChannelGraph) PruneGraph(spentOutputs []*wire.OutPoint,
|
|||||||
blockHash *chainhash.Hash, blockHeight uint32) (
|
blockHash *chainhash.Hash, blockHeight uint32) (
|
||||||
[]*models.ChannelEdgeInfo, error) {
|
[]*models.ChannelEdgeInfo, error) {
|
||||||
|
|
||||||
edges, nodes, err := c.V1Store.PruneGraph(
|
edges, nodes, err := c.Store.PruneGraph(
|
||||||
spentOutputs, blockHash, blockHeight,
|
spentOutputs, blockHash, blockHeight,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -487,7 +487,7 @@ func (c *ChannelGraph) PruneGraph(spentOutputs []*wire.OutPoint,
|
|||||||
// that we only maintain a graph of reachable nodes. In the event that a pruned
|
// that we only maintain a graph of reachable nodes. In the event that a pruned
|
||||||
// node gains more channels, it will be re-added back to the graph.
|
// node gains more channels, it will be re-added back to the graph.
|
||||||
func (c *ChannelGraph) PruneGraphNodes() error {
|
func (c *ChannelGraph) PruneGraphNodes() error {
|
||||||
nodes, err := c.V1Store.PruneGraphNodes()
|
nodes, err := c.Store.PruneGraphNodes()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -509,7 +509,7 @@ func (c *ChannelGraph) PruneGraphNodes() error {
|
|||||||
func (c *ChannelGraph) FilterKnownChanIDs(chansInfo []ChannelUpdateInfo,
|
func (c *ChannelGraph) FilterKnownChanIDs(chansInfo []ChannelUpdateInfo,
|
||||||
isZombieChan func(time.Time, time.Time) bool) ([]uint64, error) {
|
isZombieChan func(time.Time, time.Time) bool) ([]uint64, error) {
|
||||||
|
|
||||||
unknown, knownZombies, err := c.V1Store.FilterKnownChanIDs(chansInfo)
|
unknown, knownZombies, err := c.Store.FilterKnownChanIDs(chansInfo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -538,7 +538,7 @@ func (c *ChannelGraph) FilterKnownChanIDs(chansInfo []ChannelUpdateInfo,
|
|||||||
// timestamps could bring it back from the dead, then we mark it
|
// timestamps could bring it back from the dead, then we mark it
|
||||||
// alive, and we let it be added to the set of IDs to query our
|
// alive, and we let it be added to the set of IDs to query our
|
||||||
// peer for.
|
// peer for.
|
||||||
err := c.V1Store.MarkEdgeLive(
|
err := c.Store.MarkEdgeLive(
|
||||||
info.ShortChannelID.ToUint64(),
|
info.ShortChannelID.ToUint64(),
|
||||||
)
|
)
|
||||||
// Since there is a chance that the edge could have been marked
|
// Since there is a chance that the edge could have been marked
|
||||||
@@ -559,7 +559,7 @@ func (c *ChannelGraph) FilterKnownChanIDs(chansInfo []ChannelUpdateInfo,
|
|||||||
func (c *ChannelGraph) MarkEdgeZombie(chanID uint64,
|
func (c *ChannelGraph) MarkEdgeZombie(chanID uint64,
|
||||||
pubKey1, pubKey2 [33]byte) error {
|
pubKey1, pubKey2 [33]byte) error {
|
||||||
|
|
||||||
err := c.V1Store.MarkEdgeZombie(chanID, pubKey1, pubKey2)
|
err := c.Store.MarkEdgeZombie(chanID, pubKey1, pubKey2)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -581,7 +581,7 @@ func (c *ChannelGraph) MarkEdgeZombie(chanID uint64,
|
|||||||
func (c *ChannelGraph) UpdateEdgePolicy(ctx context.Context,
|
func (c *ChannelGraph) UpdateEdgePolicy(ctx context.Context,
|
||||||
edge *models.ChannelEdgePolicy, op ...batch.SchedulerOption) error {
|
edge *models.ChannelEdgePolicy, op ...batch.SchedulerOption) error {
|
||||||
|
|
||||||
from, to, err := c.V1Store.UpdateEdgePolicy(ctx, edge, op...)
|
from, to, err := c.Store.UpdateEdgePolicy(ctx, edge, op...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -602,11 +602,11 @@ func (c *ChannelGraph) UpdateEdgePolicy(ctx context.Context,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// MakeTestGraph creates a new instance of the ChannelGraph for testing
|
// MakeTestGraph creates a new instance of the ChannelGraph for testing
|
||||||
// purposes. The backing V1Store implementation depends on the version of
|
// purposes. The backing Store implementation depends on the version of
|
||||||
// NewTestDB included in the current build.
|
// NewTestDB included in the current build.
|
||||||
//
|
//
|
||||||
// NOTE: this is currently unused, but is left here for future use to show how
|
// NOTE: this is currently unused, but is left here for future use to show how
|
||||||
// NewTestDB can be used. As the SQL implementation of the V1Store is
|
// NewTestDB can be used. As the SQL implementation of the Store is
|
||||||
// implemented, unit tests will be switched to use this function instead of
|
// implemented, unit tests will be switched to use this function instead of
|
||||||
// the existing MakeTestGraph helper. Once only this function is used, the
|
// the existing MakeTestGraph helper. Once only this function is used, the
|
||||||
// existing MakeTestGraph function will be removed and this one will be renamed.
|
// existing MakeTestGraph function will be removed and this one will be renamed.
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ func TestNodeInsertionAndDeletion(t *testing.T) {
|
|||||||
|
|
||||||
// Check that the node's features are fetched correctly. This check
|
// Check that the node's features are fetched correctly. This check
|
||||||
// will check the database directly.
|
// will check the database directly.
|
||||||
features, err = graph.V1Store.FetchNodeFeatures(node.PubKeyBytes)
|
features, err = graph.Store.FetchNodeFeatures(node.PubKeyBytes)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, testFeatures, features)
|
require.Equal(t, testFeatures, features)
|
||||||
|
|
||||||
@@ -1575,7 +1575,7 @@ func TestGraphTraversalCacheable(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
// Now skip the cache and query the DB directly.
|
// Now skip the cache and query the DB directly.
|
||||||
err = graph.V1Store.ForEachNodeDirectedChannel(
|
err = graph.Store.ForEachNodeDirectedChannel(
|
||||||
node, func(d *DirectedChannel) error {
|
node, func(d *DirectedChannel) error {
|
||||||
delete(chanIndex2, d.ChannelID)
|
delete(chanIndex2, d.ChannelID)
|
||||||
return nil
|
return nil
|
||||||
@@ -3603,7 +3603,7 @@ func TestChannelEdgePruningUpdateIndexDeletion(t *testing.T) {
|
|||||||
graph := MakeTestGraph(t)
|
graph := MakeTestGraph(t)
|
||||||
|
|
||||||
// The update index only applies to the bbolt graph.
|
// The update index only applies to the bbolt graph.
|
||||||
boltStore, ok := graph.V1Store.(*KVStore)
|
boltStore, ok := graph.Store.(*KVStore)
|
||||||
if !ok {
|
if !ok {
|
||||||
t.Skipf("skipping test that is aimed at a bbolt graph DB")
|
t.Skipf("skipping test that is aimed at a bbolt graph DB")
|
||||||
}
|
}
|
||||||
@@ -4161,7 +4161,7 @@ func TestEdgePolicyMissingMaxHTLC(t *testing.T) {
|
|||||||
graph := MakeTestGraph(t)
|
graph := MakeTestGraph(t)
|
||||||
|
|
||||||
// This test currently directly edits the bytes stored in the bbolt DB.
|
// This test currently directly edits the bytes stored in the bbolt DB.
|
||||||
boltStore, ok := graph.V1Store.(*KVStore)
|
boltStore, ok := graph.Store.(*KVStore)
|
||||||
if !ok {
|
if !ok {
|
||||||
t.Skipf("skipping test that is aimed at a bbolt graph DB")
|
t.Skipf("skipping test that is aimed at a bbolt graph DB")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,9 +28,9 @@ type NodeTraverser interface {
|
|||||||
FetchNodeFeatures(nodePub route.Vertex) (*lnwire.FeatureVector, error)
|
FetchNodeFeatures(nodePub route.Vertex) (*lnwire.FeatureVector, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// V1Store represents the main interface for the channel graph database for all
|
// 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.
|
// channels and nodes gossiped via the V1 gossip protocol as defined in BOLT 7.
|
||||||
type V1Store interface { //nolint:interfacebloat
|
type Store interface { //nolint:interfacebloat
|
||||||
NodeTraverser
|
NodeTraverser
|
||||||
|
|
||||||
// AddNode adds a vertex/node to the graph database. If the
|
// AddNode adds a vertex/node to the graph database. If the
|
||||||
|
|||||||
@@ -199,8 +199,8 @@ type KVStore struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// A compile-time assertion to ensure that the KVStore struct implements the
|
// A compile-time assertion to ensure that the KVStore struct implements the
|
||||||
// V1Store interface.
|
// Store interface.
|
||||||
var _ V1Store = (*KVStore)(nil)
|
var _ Store = (*KVStore)(nil)
|
||||||
|
|
||||||
// NewKVStore allocates a new KVStore backed by a DB instance. The
|
// NewKVStore allocates a new KVStore backed by a DB instance. The
|
||||||
// returned instance has its own unique reject cache and channel cache.
|
// returned instance has its own unique reject cache and channel cache.
|
||||||
@@ -804,7 +804,7 @@ func (c *KVStore) DisabledChannelIDs() ([]uint64, error) {
|
|||||||
// returns an error, then the transaction is aborted and the iteration stops
|
// returns an error, then the transaction is aborted and the iteration stops
|
||||||
// early.
|
// early.
|
||||||
//
|
//
|
||||||
// NOTE: this is part of the V1Store interface.
|
// NOTE: this is part of the Store interface.
|
||||||
func (c *KVStore) ForEachNode(_ context.Context,
|
func (c *KVStore) ForEachNode(_ context.Context,
|
||||||
cb func(*models.Node) error, reset func()) error {
|
cb func(*models.Node) error, reset func()) error {
|
||||||
|
|
||||||
|
|||||||
+44
-44
@@ -163,7 +163,7 @@ type BatchedSQLQueries interface {
|
|||||||
sqldb.BatchedTx[SQLQueries]
|
sqldb.BatchedTx[SQLQueries]
|
||||||
}
|
}
|
||||||
|
|
||||||
// SQLStore is an implementation of the V1Store interface that uses a SQL
|
// SQLStore is an implementation of the Store interface that uses a SQL
|
||||||
// database as the backend.
|
// database as the backend.
|
||||||
type SQLStore struct {
|
type SQLStore struct {
|
||||||
cfg *SQLStoreConfig
|
cfg *SQLStoreConfig
|
||||||
@@ -183,9 +183,9 @@ type SQLStore struct {
|
|||||||
srcNodeMu sync.Mutex
|
srcNodeMu sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
// A compile-time assertion to ensure that SQLStore implements the V1Store
|
// A compile-time assertion to ensure that SQLStore implements the Store
|
||||||
// interface.
|
// interface.
|
||||||
var _ V1Store = (*SQLStore)(nil)
|
var _ Store = (*SQLStore)(nil)
|
||||||
|
|
||||||
// SQLStoreConfig holds the configuration for the SQLStore.
|
// SQLStoreConfig holds the configuration for the SQLStore.
|
||||||
type SQLStoreConfig struct {
|
type SQLStoreConfig struct {
|
||||||
@@ -235,7 +235,7 @@ func NewSQLStore(cfg *SQLStoreConfig, db BatchedSQLQueries,
|
|||||||
// graph. If it is present from before, this will update that node's
|
// graph. If it is present from before, this will update that node's
|
||||||
// information.
|
// information.
|
||||||
//
|
//
|
||||||
// NOTE: part of the V1Store interface.
|
// NOTE: part of the Store interface.
|
||||||
func (s *SQLStore) AddNode(ctx context.Context,
|
func (s *SQLStore) AddNode(ctx context.Context,
|
||||||
node *models.Node, opts ...batch.SchedulerOption) error {
|
node *models.Node, opts ...batch.SchedulerOption) error {
|
||||||
|
|
||||||
@@ -265,7 +265,7 @@ func (s *SQLStore) AddNode(ctx context.Context,
|
|||||||
// key. If the node isn't found in the database, then ErrGraphNodeNotFound is
|
// key. If the node isn't found in the database, then ErrGraphNodeNotFound is
|
||||||
// returned.
|
// returned.
|
||||||
//
|
//
|
||||||
// NOTE: part of the V1Store interface.
|
// NOTE: part of the Store interface.
|
||||||
func (s *SQLStore) FetchNode(ctx context.Context,
|
func (s *SQLStore) FetchNode(ctx context.Context,
|
||||||
pubKey route.Vertex) (*models.Node, error) {
|
pubKey route.Vertex) (*models.Node, error) {
|
||||||
|
|
||||||
@@ -289,7 +289,7 @@ func (s *SQLStore) FetchNode(ctx context.Context,
|
|||||||
// with a true boolean. Otherwise, an empty time.Time is returned with a false
|
// with a true boolean. Otherwise, an empty time.Time is returned with a false
|
||||||
// boolean.
|
// boolean.
|
||||||
//
|
//
|
||||||
// NOTE: part of the V1Store interface.
|
// NOTE: part of the Store interface.
|
||||||
func (s *SQLStore) HasNode(ctx context.Context,
|
func (s *SQLStore) HasNode(ctx context.Context,
|
||||||
pubKey [33]byte) (time.Time, bool, error) {
|
pubKey [33]byte) (time.Time, bool, error) {
|
||||||
|
|
||||||
@@ -330,7 +330,7 @@ func (s *SQLStore) HasNode(ctx context.Context,
|
|||||||
// that the graph DB is aware of. The returned boolean indicates if the
|
// that the graph DB is aware of. The returned boolean indicates if the
|
||||||
// given node is unknown to the graph DB or not.
|
// given node is unknown to the graph DB or not.
|
||||||
//
|
//
|
||||||
// NOTE: part of the V1Store interface.
|
// NOTE: part of the Store interface.
|
||||||
func (s *SQLStore) AddrsForNode(ctx context.Context,
|
func (s *SQLStore) AddrsForNode(ctx context.Context,
|
||||||
nodePub *btcec.PublicKey) (bool, []net.Addr, error) {
|
nodePub *btcec.PublicKey) (bool, []net.Addr, error) {
|
||||||
|
|
||||||
@@ -372,7 +372,7 @@ func (s *SQLStore) AddrsForNode(ctx context.Context,
|
|||||||
// DeleteNode starts a new database transaction to remove a vertex/node
|
// DeleteNode starts a new database transaction to remove a vertex/node
|
||||||
// from the database according to the node's public key.
|
// from the database according to the node's public key.
|
||||||
//
|
//
|
||||||
// NOTE: part of the V1Store interface.
|
// NOTE: part of the Store interface.
|
||||||
func (s *SQLStore) DeleteNode(ctx context.Context,
|
func (s *SQLStore) DeleteNode(ctx context.Context,
|
||||||
pubKey route.Vertex) error {
|
pubKey route.Vertex) error {
|
||||||
|
|
||||||
@@ -423,7 +423,7 @@ func (s *SQLStore) FetchNodeFeatures(nodePub route.Vertex) (
|
|||||||
// A channel is disabled when two of the associated ChanelEdgePolicies
|
// A channel is disabled when two of the associated ChanelEdgePolicies
|
||||||
// have their disabled bit on.
|
// have their disabled bit on.
|
||||||
//
|
//
|
||||||
// NOTE: part of the V1Store interface.
|
// NOTE: part of the Store interface.
|
||||||
func (s *SQLStore) DisabledChannelIDs() ([]uint64, error) {
|
func (s *SQLStore) DisabledChannelIDs() ([]uint64, error) {
|
||||||
var (
|
var (
|
||||||
ctx = context.TODO()
|
ctx = context.TODO()
|
||||||
@@ -450,7 +450,7 @@ func (s *SQLStore) DisabledChannelIDs() ([]uint64, error) {
|
|||||||
|
|
||||||
// LookupAlias attempts to return the alias as advertised by the target node.
|
// LookupAlias attempts to return the alias as advertised by the target node.
|
||||||
//
|
//
|
||||||
// NOTE: part of the V1Store interface.
|
// NOTE: part of the Store interface.
|
||||||
func (s *SQLStore) LookupAlias(ctx context.Context,
|
func (s *SQLStore) LookupAlias(ctx context.Context,
|
||||||
pub *btcec.PublicKey) (string, error) {
|
pub *btcec.PublicKey) (string, error) {
|
||||||
|
|
||||||
@@ -488,7 +488,7 @@ func (s *SQLStore) LookupAlias(ctx context.Context,
|
|||||||
// a path finding algorithm in order to explore the reachability of another
|
// a path finding algorithm in order to explore the reachability of another
|
||||||
// node based off the source node.
|
// node based off the source node.
|
||||||
//
|
//
|
||||||
// NOTE: part of the V1Store interface.
|
// NOTE: part of the Store interface.
|
||||||
func (s *SQLStore) SourceNode(ctx context.Context) (*models.Node,
|
func (s *SQLStore) SourceNode(ctx context.Context) (*models.Node,
|
||||||
error) {
|
error) {
|
||||||
|
|
||||||
@@ -517,7 +517,7 @@ func (s *SQLStore) SourceNode(ctx context.Context) (*models.Node,
|
|||||||
// node is to be used as the center of a star-graph within path finding
|
// node is to be used as the center of a star-graph within path finding
|
||||||
// algorithms.
|
// algorithms.
|
||||||
//
|
//
|
||||||
// NOTE: part of the V1Store interface.
|
// NOTE: part of the Store interface.
|
||||||
func (s *SQLStore) SetSourceNode(ctx context.Context,
|
func (s *SQLStore) SetSourceNode(ctx context.Context,
|
||||||
node *models.Node) error {
|
node *models.Node) error {
|
||||||
|
|
||||||
@@ -562,7 +562,7 @@ func (s *SQLStore) SetSourceNode(ctx context.Context,
|
|||||||
// nodes to quickly determine if they have the same set of up to date node
|
// nodes to quickly determine if they have the same set of up to date node
|
||||||
// announcements.
|
// announcements.
|
||||||
//
|
//
|
||||||
// NOTE: This is part of the V1Store interface.
|
// NOTE: This is part of the Store interface.
|
||||||
func (s *SQLStore) NodeUpdatesInHorizon(startTime, endTime time.Time,
|
func (s *SQLStore) NodeUpdatesInHorizon(startTime, endTime time.Time,
|
||||||
opts ...IteratorOption) iter.Seq2[*models.Node, error] {
|
opts ...IteratorOption) iter.Seq2[*models.Node, error] {
|
||||||
|
|
||||||
@@ -671,7 +671,7 @@ func (s *SQLStore) NodeUpdatesInHorizon(startTime, endTime time.Time,
|
|||||||
// supports. The chanPoint and chanID are used to uniquely identify the edge
|
// supports. The chanPoint and chanID are used to uniquely identify the edge
|
||||||
// globally within the database.
|
// globally within the database.
|
||||||
//
|
//
|
||||||
// NOTE: part of the V1Store interface.
|
// NOTE: part of the Store interface.
|
||||||
func (s *SQLStore) AddChannelEdge(ctx context.Context,
|
func (s *SQLStore) AddChannelEdge(ctx context.Context,
|
||||||
edge *models.ChannelEdgeInfo, opts ...batch.SchedulerOption) error {
|
edge *models.ChannelEdgeInfo, opts ...batch.SchedulerOption) error {
|
||||||
|
|
||||||
@@ -726,7 +726,7 @@ func (s *SQLStore) AddChannelEdge(ctx context.Context,
|
|||||||
// This represents the "newest" channel from the PoV of the chain. This method
|
// This represents the "newest" channel from the PoV of the chain. This method
|
||||||
// can be used by peers to quickly determine if their graphs are in sync.
|
// can be used by peers to quickly determine if their graphs are in sync.
|
||||||
//
|
//
|
||||||
// NOTE: This is part of the V1Store interface.
|
// NOTE: This is part of the Store interface.
|
||||||
func (s *SQLStore) HighestChanID(ctx context.Context) (uint64, error) {
|
func (s *SQLStore) HighestChanID(ctx context.Context) (uint64, error) {
|
||||||
var highestChanID uint64
|
var highestChanID uint64
|
||||||
err := s.db.ExecTx(ctx, sqldb.ReadTxOpt(), func(db SQLQueries) error {
|
err := s.db.ExecTx(ctx, sqldb.ReadTxOpt(), func(db SQLQueries) error {
|
||||||
@@ -757,7 +757,7 @@ func (s *SQLStore) HighestChanID(ctx context.Context) (uint64, error) {
|
|||||||
// determined by the lexicographical ordering of the identity public keys of the
|
// determined by the lexicographical ordering of the identity public keys of the
|
||||||
// nodes on either side of the channel.
|
// nodes on either side of the channel.
|
||||||
//
|
//
|
||||||
// NOTE: part of the V1Store interface.
|
// NOTE: part of the Store interface.
|
||||||
func (s *SQLStore) UpdateEdgePolicy(ctx context.Context,
|
func (s *SQLStore) UpdateEdgePolicy(ctx context.Context,
|
||||||
edge *models.ChannelEdgePolicy,
|
edge *models.ChannelEdgePolicy,
|
||||||
opts ...batch.SchedulerOption) (route.Vertex, route.Vertex, error) {
|
opts ...batch.SchedulerOption) (route.Vertex, route.Vertex, error) {
|
||||||
@@ -855,7 +855,7 @@ func (s *SQLStore) updateEdgeCache(e *models.ChannelEdgePolicy,
|
|||||||
// channel's outpoint, whether we have a policy for the channel and the channel
|
// channel's outpoint, whether we have a policy for the channel and the channel
|
||||||
// peer's node information.
|
// peer's node information.
|
||||||
//
|
//
|
||||||
// NOTE: part of the V1Store interface.
|
// NOTE: part of the Store interface.
|
||||||
func (s *SQLStore) ForEachSourceNodeChannel(ctx context.Context,
|
func (s *SQLStore) ForEachSourceNodeChannel(ctx context.Context,
|
||||||
cb func(chanPoint wire.OutPoint, havePolicy bool,
|
cb func(chanPoint wire.OutPoint, havePolicy bool,
|
||||||
otherNode *models.Node) error, reset func()) error {
|
otherNode *models.Node) error, reset func()) error {
|
||||||
@@ -914,7 +914,7 @@ func (s *SQLStore) ForEachSourceNodeChannel(ctx context.Context,
|
|||||||
// returns an error, then the transaction is aborted and the iteration stops
|
// returns an error, then the transaction is aborted and the iteration stops
|
||||||
// early.
|
// early.
|
||||||
//
|
//
|
||||||
// NOTE: part of the V1Store interface.
|
// NOTE: part of the Store interface.
|
||||||
func (s *SQLStore) ForEachNode(ctx context.Context,
|
func (s *SQLStore) ForEachNode(ctx context.Context,
|
||||||
cb func(node *models.Node) error, reset func()) error {
|
cb func(node *models.Node) error, reset func()) error {
|
||||||
|
|
||||||
@@ -982,7 +982,7 @@ func (s *SQLStore) ForEachNodeCacheable(ctx context.Context,
|
|||||||
//
|
//
|
||||||
// Unknown policies are passed into the callback as nil values.
|
// Unknown policies are passed into the callback as nil values.
|
||||||
//
|
//
|
||||||
// NOTE: part of the V1Store interface.
|
// NOTE: part of the Store interface.
|
||||||
func (s *SQLStore) ForEachNodeChannel(ctx context.Context, nodePub route.Vertex,
|
func (s *SQLStore) ForEachNodeChannel(ctx context.Context, nodePub route.Vertex,
|
||||||
cb func(*models.ChannelEdgeInfo, *models.ChannelEdgePolicy,
|
cb func(*models.ChannelEdgeInfo, *models.ChannelEdgePolicy,
|
||||||
*models.ChannelEdgePolicy) error, reset func()) error {
|
*models.ChannelEdgePolicy) error, reset func()) error {
|
||||||
@@ -1099,7 +1099,7 @@ func (s *SQLStore) updateChanCacheBatch(edgesToCache map[uint64]ChannelEdge) {
|
|||||||
// 5. Update cache after successful batch
|
// 5. Update cache after successful batch
|
||||||
// 6. Repeat with updated pagination cursor until no more results
|
// 6. Repeat with updated pagination cursor until no more results
|
||||||
//
|
//
|
||||||
// NOTE: This is part of the V1Store interface.
|
// NOTE: This is part of the Store interface.
|
||||||
func (s *SQLStore) ChanUpdatesInHorizon(startTime, endTime time.Time,
|
func (s *SQLStore) ChanUpdatesInHorizon(startTime, endTime time.Time,
|
||||||
opts ...IteratorOption) iter.Seq2[ChannelEdge, error] {
|
opts ...IteratorOption) iter.Seq2[ChannelEdge, error] {
|
||||||
|
|
||||||
@@ -1268,7 +1268,7 @@ func (s *SQLStore) ChanUpdatesInHorizon(startTime, endTime time.Time,
|
|||||||
// result in an additional round-trip to the database, so it should only be used
|
// result in an additional round-trip to the database, so it should only be used
|
||||||
// if the addresses are actually needed.
|
// if the addresses are actually needed.
|
||||||
//
|
//
|
||||||
// NOTE: part of the V1Store interface.
|
// NOTE: part of the Store interface.
|
||||||
func (s *SQLStore) ForEachNodeCached(ctx context.Context, withAddrs bool,
|
func (s *SQLStore) ForEachNodeCached(ctx context.Context, withAddrs bool,
|
||||||
cb func(ctx context.Context, node route.Vertex, addrs []net.Addr,
|
cb func(ctx context.Context, node route.Vertex, addrs []net.Addr,
|
||||||
chans map[uint64]*DirectedChannel) error, reset func()) error {
|
chans map[uint64]*DirectedChannel) error, reset func()) error {
|
||||||
@@ -1564,7 +1564,7 @@ func (s *SQLStore) ForEachChannelCacheable(cb func(*models.CachedEdgeInfo,
|
|||||||
// for that particular channel edge routing policy will be passed into the
|
// for that particular channel edge routing policy will be passed into the
|
||||||
// callback.
|
// callback.
|
||||||
//
|
//
|
||||||
// NOTE: part of the V1Store interface.
|
// NOTE: part of the Store interface.
|
||||||
func (s *SQLStore) ForEachChannel(ctx context.Context,
|
func (s *SQLStore) ForEachChannel(ctx context.Context,
|
||||||
cb func(*models.ChannelEdgeInfo, *models.ChannelEdgePolicy,
|
cb func(*models.ChannelEdgeInfo, *models.ChannelEdgePolicy,
|
||||||
*models.ChannelEdgePolicy) error, reset func()) error {
|
*models.ChannelEdgePolicy) error, reset func()) error {
|
||||||
@@ -1582,7 +1582,7 @@ func (s *SQLStore) ForEachChannel(ctx context.Context,
|
|||||||
// timestamp info of the latest received channel update messages of the channel
|
// timestamp info of the latest received channel update messages of the channel
|
||||||
// will be included in the response.
|
// will be included in the response.
|
||||||
//
|
//
|
||||||
// NOTE: This is part of the V1Store interface.
|
// NOTE: This is part of the Store interface.
|
||||||
func (s *SQLStore) FilterChannelRange(startHeight, endHeight uint32,
|
func (s *SQLStore) FilterChannelRange(startHeight, endHeight uint32,
|
||||||
withTimestamps bool) ([]BlockChannelRange, error) {
|
withTimestamps bool) ([]BlockChannelRange, error) {
|
||||||
|
|
||||||
@@ -1702,7 +1702,7 @@ func (s *SQLStore) FilterChannelRange(startHeight, endHeight uint32,
|
|||||||
// zombie. This method is used on an ad-hoc basis, when channels need to be
|
// zombie. This method is used on an ad-hoc basis, when channels need to be
|
||||||
// marked as zombies outside the normal pruning cycle.
|
// marked as zombies outside the normal pruning cycle.
|
||||||
//
|
//
|
||||||
// NOTE: part of the V1Store interface.
|
// NOTE: part of the Store interface.
|
||||||
func (s *SQLStore) MarkEdgeZombie(chanID uint64,
|
func (s *SQLStore) MarkEdgeZombie(chanID uint64,
|
||||||
pubKey1, pubKey2 [33]byte) error {
|
pubKey1, pubKey2 [33]byte) error {
|
||||||
|
|
||||||
@@ -1736,7 +1736,7 @@ func (s *SQLStore) MarkEdgeZombie(chanID uint64,
|
|||||||
|
|
||||||
// MarkEdgeLive clears an edge from our zombie index, deeming it as live.
|
// MarkEdgeLive clears an edge from our zombie index, deeming it as live.
|
||||||
//
|
//
|
||||||
// NOTE: part of the V1Store interface.
|
// NOTE: part of the Store interface.
|
||||||
func (s *SQLStore) MarkEdgeLive(chanID uint64) error {
|
func (s *SQLStore) MarkEdgeLive(chanID uint64) error {
|
||||||
s.cacheMu.Lock()
|
s.cacheMu.Lock()
|
||||||
defer s.cacheMu.Unlock()
|
defer s.cacheMu.Unlock()
|
||||||
@@ -1787,7 +1787,7 @@ func (s *SQLStore) MarkEdgeLive(chanID uint64) error {
|
|||||||
// zombie, then the two node public keys corresponding to this edge are also
|
// zombie, then the two node public keys corresponding to this edge are also
|
||||||
// returned.
|
// returned.
|
||||||
//
|
//
|
||||||
// NOTE: part of the V1Store interface.
|
// NOTE: part of the Store interface.
|
||||||
func (s *SQLStore) IsZombieEdge(chanID uint64) (bool, [33]byte, [33]byte,
|
func (s *SQLStore) IsZombieEdge(chanID uint64) (bool, [33]byte, [33]byte,
|
||||||
error) {
|
error) {
|
||||||
|
|
||||||
@@ -1830,7 +1830,7 @@ func (s *SQLStore) IsZombieEdge(chanID uint64) (bool, [33]byte, [33]byte,
|
|||||||
|
|
||||||
// NumZombies returns the current number of zombie channels in the graph.
|
// NumZombies returns the current number of zombie channels in the graph.
|
||||||
//
|
//
|
||||||
// NOTE: part of the V1Store interface.
|
// NOTE: part of the Store interface.
|
||||||
func (s *SQLStore) NumZombies() (uint64, error) {
|
func (s *SQLStore) NumZombies() (uint64, error) {
|
||||||
var (
|
var (
|
||||||
ctx = context.TODO()
|
ctx = context.TODO()
|
||||||
@@ -1865,7 +1865,7 @@ func (s *SQLStore) NumZombies() (uint64, error) {
|
|||||||
// that resurrects the channel from its zombie state. The markZombie bool
|
// that resurrects the channel from its zombie state. The markZombie bool
|
||||||
// denotes whether to mark the channel as a zombie.
|
// denotes whether to mark the channel as a zombie.
|
||||||
//
|
//
|
||||||
// NOTE: part of the V1Store interface.
|
// NOTE: part of the Store interface.
|
||||||
func (s *SQLStore) DeleteChannelEdges(strictZombiePruning, markZombie bool,
|
func (s *SQLStore) DeleteChannelEdges(strictZombiePruning, markZombie bool,
|
||||||
chanIDs ...uint64) ([]*models.ChannelEdgeInfo, error) {
|
chanIDs ...uint64) ([]*models.ChannelEdgeInfo, error) {
|
||||||
|
|
||||||
@@ -1970,7 +1970,7 @@ func (s *SQLStore) DeleteChannelEdges(strictZombiePruning, markZombie bool,
|
|||||||
// within the database. In this case, the ChannelEdgePolicy's will be nil, and
|
// within the database. In this case, the ChannelEdgePolicy's will be nil, and
|
||||||
// the ChannelEdgeInfo will only include the public keys of each node.
|
// the ChannelEdgeInfo will only include the public keys of each node.
|
||||||
//
|
//
|
||||||
// NOTE: part of the V1Store interface.
|
// NOTE: part of the Store interface.
|
||||||
func (s *SQLStore) FetchChannelEdgesByID(chanID uint64) (
|
func (s *SQLStore) FetchChannelEdgesByID(chanID uint64) (
|
||||||
*models.ChannelEdgeInfo, *models.ChannelEdgePolicy,
|
*models.ChannelEdgeInfo, *models.ChannelEdgePolicy,
|
||||||
*models.ChannelEdgePolicy, error) {
|
*models.ChannelEdgePolicy, error) {
|
||||||
@@ -2067,7 +2067,7 @@ func (s *SQLStore) FetchChannelEdgesByID(chanID uint64) (
|
|||||||
// information for the channel itself is returned as well as two structs that
|
// information for the channel itself is returned as well as two structs that
|
||||||
// contain the routing policies for the channel in either direction.
|
// contain the routing policies for the channel in either direction.
|
||||||
//
|
//
|
||||||
// NOTE: part of the V1Store interface.
|
// NOTE: part of the Store interface.
|
||||||
func (s *SQLStore) FetchChannelEdgesByOutpoint(op *wire.OutPoint) (
|
func (s *SQLStore) FetchChannelEdgesByOutpoint(op *wire.OutPoint) (
|
||||||
*models.ChannelEdgeInfo, *models.ChannelEdgePolicy,
|
*models.ChannelEdgeInfo, *models.ChannelEdgePolicy,
|
||||||
*models.ChannelEdgePolicy, error) {
|
*models.ChannelEdgePolicy, error) {
|
||||||
@@ -2137,7 +2137,7 @@ func (s *SQLStore) FetchChannelEdgesByOutpoint(op *wire.OutPoint) (
|
|||||||
// it is not found, then the zombie index is checked and its result is returned
|
// it is not found, then the zombie index is checked and its result is returned
|
||||||
// as the second boolean.
|
// as the second boolean.
|
||||||
//
|
//
|
||||||
// NOTE: part of the V1Store interface.
|
// NOTE: part of the Store interface.
|
||||||
func (s *SQLStore) HasChannelEdge(chanID uint64) (time.Time, time.Time, bool,
|
func (s *SQLStore) HasChannelEdge(chanID uint64) (time.Time, time.Time, bool,
|
||||||
bool, error) {
|
bool, error) {
|
||||||
|
|
||||||
@@ -2253,7 +2253,7 @@ func (s *SQLStore) HasChannelEdge(chanID uint64) (time.Time, time.Time, bool,
|
|||||||
// passed channel point (outpoint). If the passed channel doesn't exist within
|
// passed channel point (outpoint). If the passed channel doesn't exist within
|
||||||
// the database, then ErrEdgeNotFound is returned.
|
// the database, then ErrEdgeNotFound is returned.
|
||||||
//
|
//
|
||||||
// NOTE: part of the V1Store interface.
|
// NOTE: part of the Store interface.
|
||||||
func (s *SQLStore) ChannelID(chanPoint *wire.OutPoint) (uint64, error) {
|
func (s *SQLStore) ChannelID(chanPoint *wire.OutPoint) (uint64, error) {
|
||||||
var (
|
var (
|
||||||
ctx = context.TODO()
|
ctx = context.TODO()
|
||||||
@@ -2288,7 +2288,7 @@ func (s *SQLStore) ChannelID(chanPoint *wire.OutPoint) (uint64, error) {
|
|||||||
// given public key is seen as a public node in the graph from the graph's
|
// given public key is seen as a public node in the graph from the graph's
|
||||||
// source node's point of view.
|
// source node's point of view.
|
||||||
//
|
//
|
||||||
// NOTE: part of the V1Store interface.
|
// NOTE: part of the Store interface.
|
||||||
func (s *SQLStore) IsPublicNode(pubKey [33]byte) (bool, error) {
|
func (s *SQLStore) IsPublicNode(pubKey [33]byte) (bool, error) {
|
||||||
ctx := context.TODO()
|
ctx := context.TODO()
|
||||||
|
|
||||||
@@ -2313,7 +2313,7 @@ func (s *SQLStore) IsPublicNode(pubKey [33]byte) (bool, error) {
|
|||||||
// of the query. This can be used to respond to peer queries that are seeking to
|
// of the query. This can be used to respond to peer queries that are seeking to
|
||||||
// fill in gaps in their view of the channel graph.
|
// fill in gaps in their view of the channel graph.
|
||||||
//
|
//
|
||||||
// NOTE: part of the V1Store interface.
|
// NOTE: part of the Store interface.
|
||||||
func (s *SQLStore) FetchChanInfos(chanIDs []uint64) ([]ChannelEdge, error) {
|
func (s *SQLStore) FetchChanInfos(chanIDs []uint64) ([]ChannelEdge, error) {
|
||||||
var (
|
var (
|
||||||
ctx = context.TODO()
|
ctx = context.TODO()
|
||||||
@@ -2407,7 +2407,7 @@ func (s *SQLStore) forEachChanWithPoliciesInSCIDList(ctx context.Context,
|
|||||||
// channels another peer knows of that we don't. The ChannelUpdateInfos for the
|
// channels another peer knows of that we don't. The ChannelUpdateInfos for the
|
||||||
// known zombies is also returned.
|
// known zombies is also returned.
|
||||||
//
|
//
|
||||||
// NOTE: part of the V1Store interface.
|
// NOTE: part of the Store interface.
|
||||||
func (s *SQLStore) FilterKnownChanIDs(chansInfo []ChannelUpdateInfo) ([]uint64,
|
func (s *SQLStore) FilterKnownChanIDs(chansInfo []ChannelUpdateInfo) ([]uint64,
|
||||||
[]ChannelUpdateInfo, error) {
|
[]ChannelUpdateInfo, error) {
|
||||||
|
|
||||||
@@ -2531,7 +2531,7 @@ func (s *SQLStore) forEachChanInSCIDList(ctx context.Context, db SQLQueries,
|
|||||||
// NOTE: this prunes nodes across protocol versions. It will never prune the
|
// NOTE: this prunes nodes across protocol versions. It will never prune the
|
||||||
// source nodes.
|
// source nodes.
|
||||||
//
|
//
|
||||||
// NOTE: part of the V1Store interface.
|
// NOTE: part of the Store interface.
|
||||||
func (s *SQLStore) PruneGraphNodes() ([]route.Vertex, error) {
|
func (s *SQLStore) PruneGraphNodes() ([]route.Vertex, error) {
|
||||||
var ctx = context.TODO()
|
var ctx = context.TODO()
|
||||||
|
|
||||||
@@ -2560,7 +2560,7 @@ func (s *SQLStore) PruneGraphNodes() ([]route.Vertex, error) {
|
|||||||
// the target block along with any pruned nodes are returned if the function
|
// the target block along with any pruned nodes are returned if the function
|
||||||
// succeeds without error.
|
// succeeds without error.
|
||||||
//
|
//
|
||||||
// NOTE: part of the V1Store interface.
|
// NOTE: part of the Store interface.
|
||||||
func (s *SQLStore) PruneGraph(spentOutputs []*wire.OutPoint,
|
func (s *SQLStore) PruneGraph(spentOutputs []*wire.OutPoint,
|
||||||
blockHash *chainhash.Hash, blockHeight uint32) (
|
blockHash *chainhash.Hash, blockHeight uint32) (
|
||||||
[]*models.ChannelEdgeInfo, []route.Vertex, error) {
|
[]*models.ChannelEdgeInfo, []route.Vertex, error) {
|
||||||
@@ -2715,7 +2715,7 @@ func (s *SQLStore) deleteChannels(ctx context.Context, db SQLQueries,
|
|||||||
// returned are the ones that need to be watched on chain to detect channel
|
// returned are the ones that need to be watched on chain to detect channel
|
||||||
// closes on the resident blockchain.
|
// closes on the resident blockchain.
|
||||||
//
|
//
|
||||||
// NOTE: part of the V1Store interface.
|
// NOTE: part of the Store interface.
|
||||||
func (s *SQLStore) ChannelView() ([]EdgePoint, error) {
|
func (s *SQLStore) ChannelView() ([]EdgePoint, error) {
|
||||||
var (
|
var (
|
||||||
ctx = context.TODO()
|
ctx = context.TODO()
|
||||||
@@ -2781,7 +2781,7 @@ func (s *SQLStore) ChannelView() ([]EdgePoint, error) {
|
|||||||
// to tell if the graph is currently in sync with the current best known UTXO
|
// to tell if the graph is currently in sync with the current best known UTXO
|
||||||
// state.
|
// state.
|
||||||
//
|
//
|
||||||
// NOTE: part of the V1Store interface.
|
// NOTE: part of the Store interface.
|
||||||
func (s *SQLStore) PruneTip() (*chainhash.Hash, uint32, error) {
|
func (s *SQLStore) PruneTip() (*chainhash.Hash, uint32, error) {
|
||||||
var (
|
var (
|
||||||
ctx = context.TODO()
|
ctx = context.TODO()
|
||||||
@@ -2843,7 +2843,7 @@ func (s *SQLStore) pruneGraphNodes(ctx context.Context,
|
|||||||
// Channels that were removed from the graph resulting from the
|
// Channels that were removed from the graph resulting from the
|
||||||
// disconnected block are returned.
|
// disconnected block are returned.
|
||||||
//
|
//
|
||||||
// NOTE: part of the V1Store interface.
|
// NOTE: part of the Store interface.
|
||||||
func (s *SQLStore) DisconnectBlockAtHeight(height uint32) (
|
func (s *SQLStore) DisconnectBlockAtHeight(height uint32) (
|
||||||
[]*models.ChannelEdgeInfo, error) {
|
[]*models.ChannelEdgeInfo, error) {
|
||||||
|
|
||||||
@@ -2931,7 +2931,7 @@ func (s *SQLStore) DisconnectBlockAtHeight(height uint32) (
|
|||||||
|
|
||||||
// AddEdgeProof sets the proof of an existing edge in the graph database.
|
// AddEdgeProof sets the proof of an existing edge in the graph database.
|
||||||
//
|
//
|
||||||
// NOTE: part of the V1Store interface.
|
// NOTE: part of the Store interface.
|
||||||
func (s *SQLStore) AddEdgeProof(scid lnwire.ShortChannelID,
|
func (s *SQLStore) AddEdgeProof(scid lnwire.ShortChannelID,
|
||||||
proof *models.ChannelAuthProof) error {
|
proof *models.ChannelAuthProof) error {
|
||||||
|
|
||||||
@@ -2981,7 +2981,7 @@ func (s *SQLStore) AddEdgeProof(scid lnwire.ShortChannelID,
|
|||||||
// that we can ignore channel announcements that we know to be closed without
|
// that we can ignore channel announcements that we know to be closed without
|
||||||
// having to validate them and fetch a block.
|
// having to validate them and fetch a block.
|
||||||
//
|
//
|
||||||
// NOTE: part of the V1Store interface.
|
// NOTE: part of the Store interface.
|
||||||
func (s *SQLStore) PutClosedScid(scid lnwire.ShortChannelID) error {
|
func (s *SQLStore) PutClosedScid(scid lnwire.ShortChannelID) error {
|
||||||
var (
|
var (
|
||||||
ctx = context.TODO()
|
ctx = context.TODO()
|
||||||
@@ -2996,7 +2996,7 @@ func (s *SQLStore) PutClosedScid(scid lnwire.ShortChannelID) error {
|
|||||||
// IsClosedScid checks whether a channel identified by the passed in scid is
|
// IsClosedScid checks whether a channel identified by the passed in scid is
|
||||||
// closed. This helps avoid having to perform expensive validation checks.
|
// closed. This helps avoid having to perform expensive validation checks.
|
||||||
//
|
//
|
||||||
// NOTE: part of the V1Store interface.
|
// NOTE: part of the Store interface.
|
||||||
func (s *SQLStore) IsClosedScid(scid lnwire.ShortChannelID) (bool, error) {
|
func (s *SQLStore) IsClosedScid(scid lnwire.ShortChannelID) (bool, error) {
|
||||||
var (
|
var (
|
||||||
ctx = context.TODO()
|
ctx = context.TODO()
|
||||||
@@ -3024,7 +3024,7 @@ func (s *SQLStore) IsClosedScid(scid lnwire.ShortChannelID) (bool, error) {
|
|||||||
// GraphSession will provide the call-back with access to a NodeTraverser
|
// GraphSession will provide the call-back with access to a NodeTraverser
|
||||||
// instance which can be used to perform queries against the channel graph.
|
// instance which can be used to perform queries against the channel graph.
|
||||||
//
|
//
|
||||||
// NOTE: part of the V1Store interface.
|
// NOTE: part of the Store interface.
|
||||||
func (s *SQLStore) GraphSession(cb func(graph NodeTraverser) error,
|
func (s *SQLStore) GraphSession(cb func(graph NodeTraverser) error,
|
||||||
reset func()) error {
|
reset func()) error {
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// NewTestDB is a helper function that creates an BBolt database for testing.
|
// NewTestDB is a helper function that creates an BBolt database for testing.
|
||||||
func NewTestDB(t testing.TB) V1Store {
|
func NewTestDB(t testing.TB) Store {
|
||||||
backend, backendCleanup, err := kvdb.GetTestBackend(t.TempDir(), "cgr")
|
backend, backendCleanup, err := kvdb.GetTestBackend(t.TempDir(), "cgr")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import (
|
|||||||
|
|
||||||
// NewTestDB is a helper function that creates a SQLStore backed by a SQL
|
// NewTestDB is a helper function that creates a SQLStore backed by a SQL
|
||||||
// database for testing.
|
// database for testing.
|
||||||
func NewTestDB(t testing.TB) V1Store {
|
func NewTestDB(t testing.TB) Store {
|
||||||
return NewTestDBWithFixture(t, nil)
|
return NewTestDBWithFixture(t, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,7 +31,7 @@ func NewTestDBFixture(t *testing.T) *sqldb.TestPgFixture {
|
|||||||
// NewTestDBWithFixture is a helper function that creates a SQLStore backed by a
|
// NewTestDBWithFixture is a helper function that creates a SQLStore backed by a
|
||||||
// SQL database for testing.
|
// SQL database for testing.
|
||||||
func NewTestDBWithFixture(t testing.TB,
|
func NewTestDBWithFixture(t testing.TB,
|
||||||
pgFixture *sqldb.TestPgFixture) V1Store {
|
pgFixture *sqldb.TestPgFixture) Store {
|
||||||
|
|
||||||
var querier BatchedSQLQueries
|
var querier BatchedSQLQueries
|
||||||
if pgFixture == nil {
|
if pgFixture == nil {
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import (
|
|||||||
|
|
||||||
// NewTestDB is a helper function that creates a SQLStore backed by a SQL
|
// NewTestDB is a helper function that creates a SQLStore backed by a SQL
|
||||||
// database for testing.
|
// database for testing.
|
||||||
func NewTestDB(t testing.TB) V1Store {
|
func NewTestDB(t testing.TB) Store {
|
||||||
return NewTestDBWithFixture(t, nil)
|
return NewTestDBWithFixture(t, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -24,7 +24,7 @@ func NewTestDBFixture(_ *testing.T) *sqldb.TestPgFixture {
|
|||||||
|
|
||||||
// NewTestDBWithFixture is a helper function that creates a SQLStore backed by a
|
// NewTestDBWithFixture is a helper function that creates a SQLStore backed by a
|
||||||
// SQL database for testing.
|
// SQL database for testing.
|
||||||
func NewTestDBWithFixture(t testing.TB, _ *sqldb.TestPgFixture) V1Store {
|
func NewTestDBWithFixture(t testing.TB, _ *sqldb.TestPgFixture) Store {
|
||||||
store, err := NewSQLStore(
|
store, err := NewSQLStore(
|
||||||
&SQLStoreConfig{
|
&SQLStoreConfig{
|
||||||
ChainHash: *chaincfg.MainNetParams.GenesisHash,
|
ChainHash: *chaincfg.MainNetParams.GenesisHash,
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ func testGraphMigration(ht *lntest.HarnessTest) {
|
|||||||
|
|
||||||
// assertDBState is a helper function that asserts the state of the
|
// assertDBState is a helper function that asserts the state of the
|
||||||
// graph DB.
|
// graph DB.
|
||||||
assertDBState := func(db graphdb.V1Store) {
|
assertDBState := func(db graphdb.Store) {
|
||||||
var (
|
var (
|
||||||
numNodes int
|
numNodes int
|
||||||
edges = make(map[uint64]bool)
|
edges = make(map[uint64]bool)
|
||||||
@@ -127,7 +127,7 @@ func testGraphMigration(ht *lntest.HarnessTest) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func openNativeSQLGraphDB(ht *lntest.HarnessTest,
|
func openNativeSQLGraphDB(ht *lntest.HarnessTest,
|
||||||
hn *node.HarnessNode) graphdb.V1Store {
|
hn *node.HarnessNode) graphdb.Store {
|
||||||
|
|
||||||
db := openNativeSQLDB(ht, hn)
|
db := openNativeSQLDB(ht, hn)
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user