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)
channel.LastUpdate = &t
channel.Policy1 = protoToRoutingPolicy(resp.Node1Policy)
channel.Policy2 = protoToRoutingPolicy(resp.Node2Policy)
channel.LocalPolicy = protoToRoutingPolicy(resp.Node1Policy)
channel.RemotePolicy = protoToRoutingPolicy(resp.Node2Policy)
info, err := clt.GetInfo(ctx, &lnrpc.GetInfoRequest{})
if err != nil {
return errors.WithStack(err)
}
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

@ -274,11 +274,11 @@ func nodeProtoToNode(resp *lnrpc.NodeInfo) *models.Node {
ID: c.ChannelId,
ChannelPoint: c.ChanPoint,
Capacity: c.Capacity,
Policy1: protoToRoutingPolicy(c.Node1Policy),
Policy2: protoToRoutingPolicy(c.Node2Policy),
LocalPolicy: protoToRoutingPolicy(c.Node1Policy),
RemotePolicy: protoToRoutingPolicy(c.Node2Policy),
}
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)
}

@ -58,7 +58,7 @@ func (b *Backend) SubscribeGraphEvents(ctx context.Context, channel chan *models
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
}

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

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

@ -61,7 +61,7 @@ func (m *Models) RefreshChannels(ctx context.Context) error {
channel := m.Channels.GetByChanPoint(channels[i].ChannelPoint)
if channel != nil &&
(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])
if err != nil {
return err

@ -218,10 +218,10 @@ func (c *Channel) display() {
disabledOut := 0
disabledIn := 0
for _, ch := range c.channels.CurrentNode.Channels {
if ch.Policy1 != nil && ch.Policy1.Disabled {
if ch.LocalPolicy != nil && ch.LocalPolicy.Disabled {
disabledOut++
}
if ch.Policy2 != nil && ch.Policy2.Disabled {
if ch.RemotePolicy != nil && ch.RemotePolicy.Disabled {
disabledIn++
}
}
@ -230,12 +230,12 @@ func (c *Channel) display() {
}
}
if channel.Policy1 != nil {
printPolicy(v, p, channel.Policy1, true)
if channel.LocalPolicy != nil {
printPolicy(v, p, channel.LocalPolicy, true)
}
if channel.Policy2 != nil {
printPolicy(v, p, channel.Policy2, false)
if channel.RemotePolicy != nil {
printPolicy(v, p, channel.RemotePolicy, false)
}
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 {
var c1f uint64
var c2f uint64
if c1.Policy1 != nil {
c1f = uint64(c1.Policy1.FeeBaseMsat)
if c1.LocalPolicy != nil {
c1f = uint64(c1.LocalPolicy.FeeBaseMsat)
}
if c2.Policy1 != nil {
c2f = uint64(c2.Policy1.FeeBaseMsat)
if c2.LocalPolicy != nil {
c2f = uint64(c2.LocalPolicy.FeeBaseMsat)
}
return models.UInt64Sort(c1f, c2f, order)
}
},
display: func(c *netmodels.Channel, opts ...color.Option) string {
var val int64
if c.Policy1 != nil {
val = c.Policy1.FeeBaseMsat
if c.LocalPolicy != nil {
val = c.LocalPolicy.FeeBaseMsat
}
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 {
var c1f uint64
var c2f uint64
if c1.Policy1 != nil {
c1f = uint64(c1.Policy1.FeeRateMilliMsat)
if c1.LocalPolicy != nil {
c1f = uint64(c1.LocalPolicy.FeeRateMilliMsat)
}
if c2.Policy1 != nil {
c2f = uint64(c2.Policy1.FeeRateMilliMsat)
if c2.LocalPolicy != nil {
c2f = uint64(c2.LocalPolicy.FeeRateMilliMsat)
}
return models.UInt64Sort(c1f, c2f, order)
}
},
display: func(c *netmodels.Channel, opts ...color.Option) string {
var val int64
if c.Policy1 != nil {
val = c.Policy1.FeeRateMilliMsat
if c.LocalPolicy != nil {
val = c.LocalPolicy.FeeRateMilliMsat
}
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 {
var c1f uint64
var c2f uint64
if c1.Policy2 != nil {
c1f = uint64(c1.Policy2.FeeBaseMsat)
if c1.RemotePolicy != nil {
c1f = uint64(c1.RemotePolicy.FeeBaseMsat)
}
if c2.Policy2 != nil {
c2f = uint64(c2.Policy2.FeeBaseMsat)
if c2.RemotePolicy != nil {
c2f = uint64(c2.RemotePolicy.FeeBaseMsat)
}
return models.UInt64Sort(c1f, c2f, order)
}
},
display: func(c *netmodels.Channel, opts ...color.Option) string {
var val int64
if c.Policy2 != nil {
val = c.Policy2.FeeBaseMsat
if c.RemotePolicy != nil {
val = c.RemotePolicy.FeeBaseMsat
}
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 {
var c1f uint64
var c2f uint64
if c1.Policy2 != nil {
c1f = uint64(c1.Policy2.FeeRateMilliMsat)
if c1.RemotePolicy != nil {
c1f = uint64(c1.RemotePolicy.FeeRateMilliMsat)
}
if c2.Policy2 != nil {
c2f = uint64(c2.Policy2.FeeRateMilliMsat)
if c2.RemotePolicy != nil {
c2f = uint64(c2.RemotePolicy.FeeRateMilliMsat)
}
return models.UInt64Sort(c1f, c2f, order)
}
},
display: func(c *netmodels.Channel, opts ...color.Option) string {
var val int64
if c.Policy2 != nil {
val = c.Policy2.FeeRateMilliMsat
if c.RemotePolicy != nil {
val = c.RemotePolicy.FeeRateMilliMsat
}
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 {
outgoing := false
incoming := false
if c.Policy1 != nil && c.Policy1.Disabled {
if c.LocalPolicy != nil && c.LocalPolicy.Disabled {
outgoing = true
}
if c.Policy2 != nil && c.Policy2.Disabled {
if c.RemotePolicy != nil && c.RemotePolicy.Disabled {
incoming = true
}
result := ""

Loading…
Cancel
Save