multi: move DB schemas to channeldb/models

This commit moves the ChannelEdgePolicy, ChannelEdgeInfo,
ChanelAuthProof and CachedEdgePolicy structs to the `channeldb/models`
package.
This commit is contained in:
Elle Mouton committed 2023-11-08 14:50:35 +02:00
1 parent be23986eda
commit 84cdcd6847
45 files changed
+1028 -968

No files matched your search

+10 -9
View File
@@ -38,6 +38,7 @@ import (
"github.com/lightningnetwork/lnd/chanbackup"
"github.com/lightningnetwork/lnd/chanfitness"
"github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/channeldb/models"
"github.com/lightningnetwork/lnd/channelnotifier"
"github.com/lightningnetwork/lnd/contractcourt"
"github.com/lightningnetwork/lnd/discovery"
@@ -5921,8 +5922,8 @@ func (r *rpcServer) DescribeGraph(ctx context.Context,
// Next, for each active channel we know of within the graph, create a
// similar response which details both the edge information as well as
// the routing policies of th nodes connecting the two edges.
err = graph.ForEachChannel(func(edgeInfo *channeldb.ChannelEdgeInfo,
c1, c2 *channeldb.ChannelEdgePolicy) error {
err = graph.ForEachChannel(func(edgeInfo *models.ChannelEdgeInfo,
c1, c2 *models.ChannelEdgePolicy) error {
// Do not include unannounced channels unless specifically
// requested. Unannounced channels include both private channels as
@@ -5977,8 +5978,8 @@ func marshalExtraOpaqueData(data []byte) map[uint64][]byte {
return records
}
func marshalDbEdge(edgeInfo *channeldb.ChannelEdgeInfo,
c1, c2 *channeldb.ChannelEdgePolicy) *lnrpc.ChannelEdge {
func marshalDbEdge(edgeInfo *models.ChannelEdgeInfo,
c1, c2 *models.ChannelEdgePolicy) *lnrpc.ChannelEdge {
// Make sure the policies match the node they belong to. c1 should point
// to the policy for NodeKey1, and c2 for NodeKey2.
@@ -6021,7 +6022,7 @@ func marshalDbEdge(edgeInfo *channeldb.ChannelEdgeInfo,
}
func marshalDBRoutingPolicy(
policy *channeldb.ChannelEdgePolicy) *lnrpc.RoutingPolicy {
policy *models.ChannelEdgePolicy) *lnrpc.RoutingPolicy {
disabled := policy.ChannelFlags&lnwire.ChanUpdateDisabled != 0
@@ -6152,8 +6153,8 @@ func (r *rpcServer) GetNodeInfo(ctx context.Context,
)
err = graph.ForEachNodeChannel(nil, node.PubKeyBytes,
func(_ kvdb.RTx, edge *channeldb.ChannelEdgeInfo,
c1, c2 *channeldb.ChannelEdgePolicy) error {
func(_ kvdb.RTx, edge *models.ChannelEdgeInfo,
c1, c2 *models.ChannelEdgePolicy) error {
numChannels++
totalCapacity += edge.Capacity
@@ -6767,8 +6768,8 @@ func (r *rpcServer) FeeReport(ctx context.Context,
var feeReports []*lnrpc.ChannelFeeReport
err = channelGraph.ForEachNodeChannel(nil, selfNode.PubKeyBytes,
func(_ kvdb.RTx, chanInfo *channeldb.ChannelEdgeInfo,
edgePolicy, _ *channeldb.ChannelEdgePolicy) error {
func(_ kvdb.RTx, chanInfo *models.ChannelEdgeInfo,
edgePolicy, _ *models.ChannelEdgePolicy) error {
// Self node should always have policies for its
// channels.