graph/db+sqldb: impl DisabledChannelIDs
Which lets us run `TestDisabledChannelIDs` against our SQL DB backends.
This commit is contained in:
6 files changed
+88
-1
No files matched your search
@@ -3592,7 +3592,7 @@ func TestDisabledChannelIDs(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
|
||||
graph := MakeTestGraph(t)
|
||||
graph := MakeTestGraphNew(t)
|
||||
|
||||
// Create first node and add it to the graph.
|
||||
node1 := createTestVertex(t)
|
||||
@@ -3608,6 +3608,7 @@ func TestDisabledChannelIDs(t *testing.T) {
|
||||
|
||||
// Adding a new channel edge to the graph.
|
||||
edgeInfo, edge1, edge2 := createChannelEdge(node1, node2)
|
||||
node2.LastUpdate = time.Unix(nextUpdateTime(), 0)
|
||||
if err := graph.AddLightningNode(ctx, node2); err != nil {
|
||||
t.Fatalf("unable to add node: %v", err)
|
||||
}
|
||||
|
||||
@@ -109,6 +109,7 @@ type SQLQueries interface {
|
||||
*/
|
||||
UpsertEdgePolicy(ctx context.Context, arg sqlc.UpsertEdgePolicyParams) (int64, error)
|
||||
GetChannelPolicyByChannelAndNode(ctx context.Context, arg sqlc.GetChannelPolicyByChannelAndNodeParams) (sqlc.ChannelPolicy, error)
|
||||
GetV1DisabledSCIDs(ctx context.Context) ([][]byte, error)
|
||||
|
||||
InsertChanPolicyExtraType(ctx context.Context, arg sqlc.InsertChanPolicyExtraTypeParams) error
|
||||
GetChannelPolicyExtraTypes(ctx context.Context, arg sqlc.GetChannelPolicyExtraTypesParams) ([]sqlc.GetChannelPolicyExtraTypesRow, error)
|
||||
@@ -372,6 +373,35 @@ func (s *SQLStore) FetchNodeFeatures(nodePub route.Vertex) (
|
||||
return fetchNodeFeatures(ctx, s.db, nodePub)
|
||||
}
|
||||
|
||||
// DisabledChannelIDs returns the channel ids of disabled channels.
|
||||
// A channel is disabled when two of the associated ChanelEdgePolicies
|
||||
// have their disabled bit on.
|
||||
//
|
||||
// NOTE: part of the V1Store interface.
|
||||
func (s *SQLStore) DisabledChannelIDs() ([]uint64, error) {
|
||||
var (
|
||||
ctx = context.TODO()
|
||||
chanIDs []uint64
|
||||
)
|
||||
err := s.db.ExecTx(ctx, sqldb.ReadTxOpt(), func(db SQLQueries) error {
|
||||
dbChanIDs, err := db.GetV1DisabledSCIDs(ctx)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to fetch disabled "+
|
||||
"channels: %w", err)
|
||||
}
|
||||
|
||||
chanIDs = fn.Map(dbChanIDs, byteOrder.Uint64)
|
||||
|
||||
return nil
|
||||
}, sqldb.NoOpReset)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to fetch disabled channels: %w",
|
||||
err)
|
||||
}
|
||||
|
||||
return chanIDs, nil
|
||||
}
|
||||
|
||||
// LookupAlias attempts to return the alias as advertised by the target node.
|
||||
//
|
||||
// NOTE: part of the V1Store interface.
|
||||
|
||||
Reference in new issue
Block a user