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
2023-11-08 11:18:45 +02:00
parent be23986eda
commit 84cdcd6847
45 changed files with 1028 additions and 968 deletions

View File

@@ -31,8 +31,8 @@ type Manager struct {
// ForAllOutgoingChannels is required to iterate over all our local
// channels.
ForAllOutgoingChannels func(cb func(kvdb.RTx,
*channeldb.ChannelEdgeInfo,
*channeldb.ChannelEdgePolicy) error) error
*models.ChannelEdgeInfo,
*models.ChannelEdgePolicy) error) error
// FetchChannel is used to query local channel parameters. Optionally an
// existing db tx can be supplied.
@@ -73,8 +73,8 @@ func (r *Manager) UpdatePolicy(newSchema routing.ChannelPolicy,
// otherwise we'll collect them all.
err := r.ForAllOutgoingChannels(func(
tx kvdb.RTx,
info *channeldb.ChannelEdgeInfo,
edge *channeldb.ChannelEdgePolicy) error {
info *models.ChannelEdgeInfo,
edge *models.ChannelEdgePolicy) error {
// If we have a channel filter, and this channel isn't a part
// of it, then we'll skip it.
@@ -172,7 +172,7 @@ func (r *Manager) UpdatePolicy(newSchema routing.ChannelPolicy,
// updateEdge updates the given edge with the new schema.
func (r *Manager) updateEdge(tx kvdb.RTx, chanPoint wire.OutPoint,
edge *channeldb.ChannelEdgePolicy,
edge *models.ChannelEdgePolicy,
newSchema routing.ChannelPolicy) error {
// Update forwarding fee scheme and required time lock delta.

View File

@@ -22,7 +22,7 @@ func TestManager(t *testing.T) {
t.Parallel()
type channel struct {
edgeInfo *channeldb.ChannelEdgeInfo
edgeInfo *models.ChannelEdgeInfo
}
var (
@@ -44,7 +44,7 @@ func TestManager(t *testing.T) {
MaxHTLC: 5000,
}
currentPolicy := channeldb.ChannelEdgePolicy{
currentPolicy := models.ChannelEdgePolicy{
MinHTLC: minHTLC,
MessageFlags: lnwire.ChanUpdateRequiredMaxHtlc,
}
@@ -107,8 +107,8 @@ func TestManager(t *testing.T) {
}
forAllOutgoingChannels := func(cb func(kvdb.RTx,
*channeldb.ChannelEdgeInfo,
*channeldb.ChannelEdgePolicy) error) error {
*models.ChannelEdgeInfo,
*models.ChannelEdgePolicy) error) error {
for _, c := range channelSet {
if err := cb(nil, c.edgeInfo, &currentPolicy); err != nil {
@@ -152,7 +152,7 @@ func TestManager(t *testing.T) {
tests := []struct {
name string
currentPolicy channeldb.ChannelEdgePolicy
currentPolicy models.ChannelEdgePolicy
newPolicy routing.ChannelPolicy
channelSet []channel
specifiedChanPoints []wire.OutPoint
@@ -166,7 +166,7 @@ func TestManager(t *testing.T) {
newPolicy: newPolicy,
channelSet: []channel{
{
edgeInfo: &channeldb.ChannelEdgeInfo{
edgeInfo: &models.ChannelEdgeInfo{
Capacity: chanCap,
ChannelPoint: chanPointValid,
},
@@ -183,7 +183,7 @@ func TestManager(t *testing.T) {
newPolicy: newPolicy,
channelSet: []channel{
{
edgeInfo: &channeldb.ChannelEdgeInfo{
edgeInfo: &models.ChannelEdgeInfo{
Capacity: chanCap,
ChannelPoint: chanPointValid,
},
@@ -200,7 +200,7 @@ func TestManager(t *testing.T) {
newPolicy: newPolicy,
channelSet: []channel{
{
edgeInfo: &channeldb.ChannelEdgeInfo{
edgeInfo: &models.ChannelEdgeInfo{
Capacity: chanCap,
ChannelPoint: chanPointValid,
},
@@ -221,7 +221,7 @@ func TestManager(t *testing.T) {
newPolicy: noMaxHtlcPolicy,
channelSet: []channel{
{
edgeInfo: &channeldb.ChannelEdgeInfo{
edgeInfo: &models.ChannelEdgeInfo{
Capacity: chanCap,
ChannelPoint: chanPointValid,
},