Rename Policy1/2 to LocalPolicy/RemotePolicy

pull/76/head
rkfg 2 years ago
parent 520e23fb92
commit 2d8e6ea6cc

@ -412,15 +412,15 @@ func (l Backend) GetChannelInfo(ctx context.Context, channel *models.Channel) er
t := time.Unix(int64(uint64(resp.LastUpdate)), 0) t := time.Unix(int64(uint64(resp.LastUpdate)), 0)
channel.LastUpdate = &t channel.LastUpdate = &t
channel.Policy1 = protoToRoutingPolicy(resp.Node1Policy) channel.LocalPolicy = protoToRoutingPolicy(resp.Node1Policy)
channel.Policy2 = protoToRoutingPolicy(resp.Node2Policy) channel.RemotePolicy = protoToRoutingPolicy(resp.Node2Policy)
info, err := clt.GetInfo(ctx, &lnrpc.GetInfoRequest{}) info, err := clt.GetInfo(ctx, &lnrpc.GetInfoRequest{})
if err != nil { if err != nil {
return errors.WithStack(err) return errors.WithStack(err)
} }
if info != nil && resp.Node1Pub != info.IdentityPubkey { if info != nil && resp.Node1Pub != info.IdentityPubkey {
channel.Policy1, channel.Policy2 = channel.Policy2, channel.Policy1 channel.LocalPolicy, channel.RemotePolicy = channel.RemotePolicy, channel.LocalPolicy
} }
return nil return nil

@ -274,11 +274,11 @@ func nodeProtoToNode(resp *lnrpc.NodeInfo) *models.Node {
ID: c.ChannelId, ID: c.ChannelId,
ChannelPoint: c.ChanPoint, ChannelPoint: c.ChanPoint,
Capacity: c.Capacity, Capacity: c.Capacity,
Policy1: protoToRoutingPolicy(c.Node1Policy), LocalPolicy: protoToRoutingPolicy(c.Node1Policy),
Policy2: protoToRoutingPolicy(c.Node2Policy), RemotePolicy: protoToRoutingPolicy(c.Node2Policy),
} }
if c.Node1Pub != resp.Node.PubKey { if c.Node1Pub != resp.Node.PubKey {
ch.Policy1, ch.Policy2 = ch.Policy2, ch.Policy1 ch.LocalPolicy, ch.RemotePolicy = ch.RemotePolicy, ch.LocalPolicy
} }
channels = append(channels, ch) channels = append(channels, ch)
} }

@ -58,7 +58,7 @@ func (b *Backend) SubscribeGraphEvents(ctx context.Context, channel chan *models
return nil return nil
} }
func (b *Backend) GetNode(ctx context.Context, pubkey string) (*models.Node, error) { func (b *Backend) GetNode(ctx context.Context, pubkey string, includeChannels bool) (*models.Node, error) {
return &models.Node{}, nil return &models.Node{}, nil
} }

@ -49,8 +49,8 @@ type Channel struct {
PendingHTLC []*HTLC PendingHTLC []*HTLC
LastUpdate *time.Time LastUpdate *time.Time
Node *Node Node *Node
Policy1 *RoutingPolicy LocalPolicy *RoutingPolicy
Policy2 *RoutingPolicy RemotePolicy *RoutingPolicy
} }
func (m Channel) MarshalLogObject(enc logging.ObjectEncoder) error { func (m Channel) MarshalLogObject(enc logging.ObjectEncoder) error {

@ -109,12 +109,12 @@ func (c *Channels) Update(newChannel *models.Channel) {
oldChannel.LastUpdate = newChannel.LastUpdate oldChannel.LastUpdate = newChannel.LastUpdate
} }
if newChannel.Policy1 != nil { if newChannel.LocalPolicy != nil {
oldChannel.Policy1 = newChannel.Policy1 oldChannel.LocalPolicy = newChannel.LocalPolicy
} }
if newChannel.Policy2 != nil { if newChannel.RemotePolicy != nil {
oldChannel.Policy2 = newChannel.Policy2 oldChannel.RemotePolicy = newChannel.RemotePolicy
} }
} }

@ -61,7 +61,7 @@ func (m *Models) RefreshChannels(ctx context.Context) error {
channel := m.Channels.GetByChanPoint(channels[i].ChannelPoint) channel := m.Channels.GetByChanPoint(channels[i].ChannelPoint)
if channel != nil && if channel != nil &&
(channel.UpdatesCount < channels[i].UpdatesCount || (channel.UpdatesCount < channels[i].UpdatesCount ||
channel.LastUpdate == nil || channel.Policy1 == nil || channel.Policy2 == nil) { channel.LastUpdate == nil || channel.LocalPolicy == nil || channel.RemotePolicy == nil) {
err := m.network.GetChannelInfo(ctx, channels[i]) err := m.network.GetChannelInfo(ctx, channels[i])
if err != nil { if err != nil {
return err return err

@ -218,10 +218,10 @@ func (c *Channel) display() {
disabledOut := 0 disabledOut := 0
disabledIn := 0 disabledIn := 0
for _, ch := range c.channels.CurrentNode.Channels { for _, ch := range c.channels.CurrentNode.Channels {
if ch.Policy1 != nil && ch.Policy1.Disabled { if ch.LocalPolicy != nil && ch.LocalPolicy.Disabled {
disabledOut++ disabledOut++
} }
if ch.Policy2 != nil && ch.Policy2.Disabled { if ch.RemotePolicy != nil && ch.RemotePolicy.Disabled {
disabledIn++ disabledIn++
} }
} }
@ -230,12 +230,12 @@ func (c *Channel) display() {
} }
} }
if channel.Policy1 != nil { if channel.LocalPolicy != nil {
printPolicy(v, p, channel.Policy1, true) printPolicy(v, p, channel.LocalPolicy, true)
} }
if channel.Policy2 != nil { if channel.RemotePolicy != nil {
printPolicy(v, p, channel.Policy2, false) printPolicy(v, p, channel.RemotePolicy, false)
} }
if len(channel.PendingHTLC) > 0 { if len(channel.PendingHTLC) > 0 {

@ -546,19 +546,19 @@ func NewChannels(cfg *config.View, chans *models.Channels) *Channels {
return func(c1, c2 *netmodels.Channel) bool { return func(c1, c2 *netmodels.Channel) bool {
var c1f uint64 var c1f uint64
var c2f uint64 var c2f uint64
if c1.Policy1 != nil { if c1.LocalPolicy != nil {
c1f = uint64(c1.Policy1.FeeBaseMsat) c1f = uint64(c1.LocalPolicy.FeeBaseMsat)
} }
if c2.Policy1 != nil { if c2.LocalPolicy != nil {
c2f = uint64(c2.Policy1.FeeBaseMsat) c2f = uint64(c2.LocalPolicy.FeeBaseMsat)
} }
return models.UInt64Sort(c1f, c2f, order) return models.UInt64Sort(c1f, c2f, order)
} }
}, },
display: func(c *netmodels.Channel, opts ...color.Option) string { display: func(c *netmodels.Channel, opts ...color.Option) string {
var val int64 var val int64
if c.Policy1 != nil { if c.LocalPolicy != nil {
val = c.Policy1.FeeBaseMsat val = c.LocalPolicy.FeeBaseMsat
} }
return color.White(opts...)(printer.Sprintf("%8d", val)) return color.White(opts...)(printer.Sprintf("%8d", val))
}, },
@ -571,19 +571,19 @@ func NewChannels(cfg *config.View, chans *models.Channels) *Channels {
return func(c1, c2 *netmodels.Channel) bool { return func(c1, c2 *netmodels.Channel) bool {
var c1f uint64 var c1f uint64
var c2f uint64 var c2f uint64
if c1.Policy1 != nil { if c1.LocalPolicy != nil {
c1f = uint64(c1.Policy1.FeeRateMilliMsat) c1f = uint64(c1.LocalPolicy.FeeRateMilliMsat)
} }
if c2.Policy1 != nil { if c2.LocalPolicy != nil {
c2f = uint64(c2.Policy1.FeeRateMilliMsat) c2f = uint64(c2.LocalPolicy.FeeRateMilliMsat)
} }
return models.UInt64Sort(c1f, c2f, order) return models.UInt64Sort(c1f, c2f, order)
} }
}, },
display: func(c *netmodels.Channel, opts ...color.Option) string { display: func(c *netmodels.Channel, opts ...color.Option) string {
var val int64 var val int64
if c.Policy1 != nil { if c.LocalPolicy != nil {
val = c.Policy1.FeeRateMilliMsat val = c.LocalPolicy.FeeRateMilliMsat
} }
return color.White(opts...)(printer.Sprintf("%8d", val)) return color.White(opts...)(printer.Sprintf("%8d", val))
}, },
@ -596,19 +596,19 @@ func NewChannels(cfg *config.View, chans *models.Channels) *Channels {
return func(c1, c2 *netmodels.Channel) bool { return func(c1, c2 *netmodels.Channel) bool {
var c1f uint64 var c1f uint64
var c2f uint64 var c2f uint64
if c1.Policy2 != nil { if c1.RemotePolicy != nil {
c1f = uint64(c1.Policy2.FeeBaseMsat) c1f = uint64(c1.RemotePolicy.FeeBaseMsat)
} }
if c2.Policy2 != nil { if c2.RemotePolicy != nil {
c2f = uint64(c2.Policy2.FeeBaseMsat) c2f = uint64(c2.RemotePolicy.FeeBaseMsat)
} }
return models.UInt64Sort(c1f, c2f, order) return models.UInt64Sort(c1f, c2f, order)
} }
}, },
display: func(c *netmodels.Channel, opts ...color.Option) string { display: func(c *netmodels.Channel, opts ...color.Option) string {
var val int64 var val int64
if c.Policy2 != nil { if c.RemotePolicy != nil {
val = c.Policy2.FeeBaseMsat val = c.RemotePolicy.FeeBaseMsat
} }
return color.White(opts...)(printer.Sprintf("%7d", val)) return color.White(opts...)(printer.Sprintf("%7d", val))
}, },
@ -621,19 +621,19 @@ func NewChannels(cfg *config.View, chans *models.Channels) *Channels {
return func(c1, c2 *netmodels.Channel) bool { return func(c1, c2 *netmodels.Channel) bool {
var c1f uint64 var c1f uint64
var c2f uint64 var c2f uint64
if c1.Policy2 != nil { if c1.RemotePolicy != nil {
c1f = uint64(c1.Policy2.FeeRateMilliMsat) c1f = uint64(c1.RemotePolicy.FeeRateMilliMsat)
} }
if c2.Policy2 != nil { if c2.RemotePolicy != nil {
c2f = uint64(c2.Policy2.FeeRateMilliMsat) c2f = uint64(c2.RemotePolicy.FeeRateMilliMsat)
} }
return models.UInt64Sort(c1f, c2f, order) return models.UInt64Sort(c1f, c2f, order)
} }
}, },
display: func(c *netmodels.Channel, opts ...color.Option) string { display: func(c *netmodels.Channel, opts ...color.Option) string {
var val int64 var val int64
if c.Policy2 != nil { if c.RemotePolicy != nil {
val = c.Policy2.FeeRateMilliMsat val = c.RemotePolicy.FeeRateMilliMsat
} }
return color.White(opts...)(printer.Sprintf("%7d", val)) return color.White(opts...)(printer.Sprintf("%7d", val))
}, },
@ -655,10 +655,10 @@ func NewChannels(cfg *config.View, chans *models.Channels) *Channels {
func channelDisabled(c *netmodels.Channel, opts ...color.Option) string { func channelDisabled(c *netmodels.Channel, opts ...color.Option) string {
outgoing := false outgoing := false
incoming := false incoming := false
if c.Policy1 != nil && c.Policy1.Disabled { if c.LocalPolicy != nil && c.LocalPolicy.Disabled {
outgoing = true outgoing = true
} }
if c.Policy2 != nil && c.Policy2.Disabled { if c.RemotePolicy != nil && c.RemotePolicy.Disabled {
incoming = true incoming = true
} }
result := "" result := ""

Loading…
Cancel
Save