mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-02-22 22:25:24 +01:00
channelnotifier: add event for fully resolved channel
We'll want to be informed about a channel that's been fully resolved on chain in case it was involved in a force close. We add a new event type and emit method for it.
This commit is contained in:
parent
90db8de6fe
commit
dcff9e5e26
1 changed files with 20 additions and 1 deletions
|
@ -65,6 +65,14 @@ type ClosedChannelEvent struct {
|
||||||
CloseSummary *channeldb.ChannelCloseSummary
|
CloseSummary *channeldb.ChannelCloseSummary
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FullyResolvedChannelEvent represents a new event where a channel becomes
|
||||||
|
// fully resolved.
|
||||||
|
type FullyResolvedChannelEvent struct {
|
||||||
|
// ChannelPoint is the channelpoint for the newly fully resolved
|
||||||
|
// channel.
|
||||||
|
ChannelPoint *wire.OutPoint
|
||||||
|
}
|
||||||
|
|
||||||
// New creates a new channel notifier. The ChannelNotifier gets channel
|
// New creates a new channel notifier. The ChannelNotifier gets channel
|
||||||
// events from peers and from the chain arbitrator, and dispatches them to
|
// events from peers and from the chain arbitrator, and dispatches them to
|
||||||
// its clients.
|
// its clients.
|
||||||
|
@ -125,7 +133,6 @@ func (c *ChannelNotifier) NotifyPendingOpenChannelEvent(chanPoint wire.OutPoint,
|
||||||
// NotifyOpenChannelEvent notifies the channelEventNotifier goroutine that a
|
// NotifyOpenChannelEvent notifies the channelEventNotifier goroutine that a
|
||||||
// channel has gone from pending open to open.
|
// channel has gone from pending open to open.
|
||||||
func (c *ChannelNotifier) NotifyOpenChannelEvent(chanPoint wire.OutPoint) {
|
func (c *ChannelNotifier) NotifyOpenChannelEvent(chanPoint wire.OutPoint) {
|
||||||
|
|
||||||
// Fetch the relevant channel from the database.
|
// Fetch the relevant channel from the database.
|
||||||
channel, err := c.chanDB.FetchChannel(chanPoint)
|
channel, err := c.chanDB.FetchChannel(chanPoint)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -155,6 +162,18 @@ func (c *ChannelNotifier) NotifyClosedChannelEvent(chanPoint wire.OutPoint) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NotifyFullyResolvedChannelEvent notifies the channelEventNotifier goroutine
|
||||||
|
// that a channel was fully resolved on chain.
|
||||||
|
func (c *ChannelNotifier) NotifyFullyResolvedChannelEvent(
|
||||||
|
chanPoint wire.OutPoint) {
|
||||||
|
|
||||||
|
// Send the resolved event to all channel event subscribers.
|
||||||
|
event := FullyResolvedChannelEvent{ChannelPoint: &chanPoint}
|
||||||
|
if err := c.ntfnServer.SendUpdate(event); err != nil {
|
||||||
|
log.Warnf("Unable to send resolved channel update: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// NotifyActiveLinkEvent notifies the channelEventNotifier goroutine that a
|
// NotifyActiveLinkEvent notifies the channelEventNotifier goroutine that a
|
||||||
// link has been added to the switch.
|
// link has been added to the switch.
|
||||||
func (c *ChannelNotifier) NotifyActiveLinkEvent(chanPoint wire.OutPoint) {
|
func (c *ChannelNotifier) NotifyActiveLinkEvent(chanPoint wire.OutPoint) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue