mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-30 07:35:07 +02:00
chanfitness: Add channel event store
This commit adds a channel event store to the channel fitness package which is used to manage tracking of a node's channels. It adds tracking for channel open/closed and peer online/offline events for all channels that a node has open. Events are consumed from channelNotifier and peerNotifier event subscriptions. If either of these subscriptions is cancelled, channel scoring stops, because both subscriptions are expected to run until node shutdown. Two functions are exposed to allow external callers to get uptime information about a channel. GetLifespan returns the period over which the channel has been monitored. GetUptime returns the channel's uptime over a specified period. Callers can use these functions to get the channel's remote peer uptime over its entire lifetime, or a subset of that period.
This commit is contained in:
@@ -73,7 +73,11 @@ func (c *ChannelNotifier) Stop() {
|
||||
}
|
||||
|
||||
// SubscribeChannelEvents returns a subscribe.Client that will receive updates
|
||||
// any time the Server is made aware of a new event.
|
||||
// any time the Server is made aware of a new event. The subscription provides
|
||||
// channel events from the point of subscription onwards.
|
||||
//
|
||||
// TODO(carlaKC): update to allow subscriptions to specify a block height from
|
||||
// which we would like to subscribe to events.
|
||||
func (c *ChannelNotifier) SubscribeChannelEvents() (*subscribe.Client, error) {
|
||||
return c.ntfnServer.Subscribe()
|
||||
}
|
||||
|
Reference in New Issue
Block a user