Fix channel age update

pull/85/head
rkfg 2 years ago
parent 8c172646b6
commit 48b7b58eee

@ -104,6 +104,7 @@ func (c *Channels) Update(newChannel *models.Channel) {
oldChannel.CSVDelay = newChannel.CSVDelay oldChannel.CSVDelay = newChannel.CSVDelay
oldChannel.Private = newChannel.Private oldChannel.Private = newChannel.Private
oldChannel.PendingHTLC = newChannel.PendingHTLC oldChannel.PendingHTLC = newChannel.PendingHTLC
oldChannel.Age = newChannel.Age
if newChannel.LastUpdate != nil { if newChannel.LastUpdate != nil {
oldChannel.LastUpdate = newChannel.LastUpdate oldChannel.LastUpdate = newChannel.LastUpdate

@ -55,6 +55,9 @@ func (m *Models) RefreshChannels(ctx context.Context) error {
index := map[string]*models.Channel{} index := map[string]*models.Channel{}
for i := range channels { for i := range channels {
index[channels[i].ChannelPoint] = channels[i] index[channels[i].ChannelPoint] = channels[i]
if channels[i].ID > 0 {
channels[i].Age = m.Info.BlockHeight - uint32(channels[i].ID>>40)
}
if !m.Channels.Contains(channels[i]) { if !m.Channels.Contains(channels[i]) {
m.Channels.Add(channels[i]) m.Channels.Add(channels[i])
} }
@ -62,9 +65,6 @@ func (m *Models) RefreshChannels(ctx context.Context) error {
if channel != nil && if channel != nil &&
(channel.UpdatesCount < channels[i].UpdatesCount || (channel.UpdatesCount < channels[i].UpdatesCount ||
channel.LastUpdate == nil || channel.LocalPolicy == nil || channel.RemotePolicy == nil) { channel.LastUpdate == nil || channel.LocalPolicy == nil || channel.RemotePolicy == nil) {
if channels[i].ID > 0 {
channels[i].Age = m.Info.BlockHeight - uint32(channels[i].ID>>40)
}
err := m.network.GetChannelInfo(ctx, channels[i]) err := m.network.GetChannelInfo(ctx, channels[i])
if err != nil { if err != nil {
return err return err

Loading…
Cancel
Save