chanfitness: switch to query by channel outpoint

In this commit, the channelEventStore in the channel
fitness subsystem is changed to identify channels
by their outpoint rather than short channel id. This
change is made made becuase outpoints are the preferred
way to expose references over rpc, and easier to perform
queries within lnd.
This commit is contained in:
carla committed 2019-12-17 17:36:28 +02:00
1 parent 47e700ba9e
commit 4f9795e8ae
4 files changed
+88 -72

No files matched your search

+10 -7
View File
@@ -4,6 +4,7 @@ import (
"fmt"
"time"
"github.com/btcsuite/btcd/wire"
"github.com/lightningnetwork/lnd/routing/route"
)
@@ -36,8 +37,8 @@ type channelEvent struct {
// chanEventLog stores all events that have occurred over a channel's lifetime.
type chanEventLog struct {
// id is the uint64 of the short channel ID.
id uint64
// channelPoint is the outpoint for the channel's funding transaction.
channelPoint wire.OutPoint
// peer is the compressed public key of the peer being monitored.
peer route.Vertex
@@ -59,11 +60,13 @@ type chanEventLog struct {
closedAt time.Time
}
func newEventLog(id uint64, peer route.Vertex, now func() time.Time) *chanEventLog {
func newEventLog(outpoint wire.OutPoint, peer route.Vertex,
now func() time.Time) *chanEventLog {
return &chanEventLog{
id: id,
peer: peer,
now: now,
channelPoint: outpoint,
peer: peer,
now: now,
}
}
@@ -95,7 +98,7 @@ func (e *chanEventLog) add(eventType eventType) {
e.openedAt = event.timestamp
}
log.Debugf("Channel %v recording event: %v", e.id, eventType)
log.Debugf("Channel %v recording event: %v", e.channelPoint, eventType)
}
// onlinePeriod represents a period of time over which a peer was online.