contractcourt/chain_arbitrator: notify the ChannelNotifier on newly closed channels.
This commit is contained in:
parent
bdd8ce14c9
commit
10090a978d
@ -141,6 +141,10 @@ type ChainArbitratorConfig struct {
|
|||||||
// the given payment hash. ErrInvoiceNotFound is returned if an invoice
|
// the given payment hash. ErrInvoiceNotFound is returned if an invoice
|
||||||
// is not found.
|
// is not found.
|
||||||
SettleInvoice func(lntypes.Hash, lnwire.MilliSatoshi) error
|
SettleInvoice func(lntypes.Hash, lnwire.MilliSatoshi) error
|
||||||
|
|
||||||
|
// NotifyClosedChannel is a function closure that the ChainArbitrator
|
||||||
|
// will use to notify the ChannelNotifier about a newly closed channel.
|
||||||
|
NotifyClosedChannel func(wire.OutPoint)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ChainArbitrator is a sub-system that oversees the on-chain resolution of all
|
// ChainArbitrator is a sub-system that oversees the on-chain resolution of all
|
||||||
@ -245,7 +249,13 @@ func newActiveChannelArbitrator(channel *channeldb.OpenChannel,
|
|||||||
return chanMachine.ForceClose()
|
return chanMachine.ForceClose()
|
||||||
},
|
},
|
||||||
MarkCommitmentBroadcasted: channel.MarkCommitmentBroadcasted,
|
MarkCommitmentBroadcasted: channel.MarkCommitmentBroadcasted,
|
||||||
MarkChannelClosed: channel.CloseChannel,
|
MarkChannelClosed: func(summary *channeldb.ChannelCloseSummary) error {
|
||||||
|
if err := channel.CloseChannel(summary); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
c.cfg.NotifyClosedChannel(summary.ChanPoint)
|
||||||
|
return nil
|
||||||
|
},
|
||||||
IsPendingClose: false,
|
IsPendingClose: false,
|
||||||
ChainArbitratorConfig: c.cfg,
|
ChainArbitratorConfig: c.cfg,
|
||||||
ChainEvents: chanEvents,
|
ChainEvents: chanEvents,
|
||||||
@ -719,13 +729,7 @@ func (c *ChainArbitrator) WatchNewChannel(newChan *channeldb.OpenChannel) error
|
|||||||
// SubscribeChannelEvents returns a new active subscription for the set of
|
// SubscribeChannelEvents returns a new active subscription for the set of
|
||||||
// possible on-chain events for a particular channel. The struct can be used by
|
// possible on-chain events for a particular channel. The struct can be used by
|
||||||
// callers to be notified whenever an event that changes the state of the
|
// callers to be notified whenever an event that changes the state of the
|
||||||
// channel on-chain occurs. If syncDispatch is true, then the sender of the
|
// channel on-chain occurs.
|
||||||
// notification will wait until an error is sent over the ProcessACK before
|
|
||||||
// modifying any database state. This allows callers to request a reliable hand
|
|
||||||
// off.
|
|
||||||
//
|
|
||||||
// TODO(roasbeef): can be used later to provide RPC hook for all channel
|
|
||||||
// lifetimes
|
|
||||||
func (c *ChainArbitrator) SubscribeChannelEvents(
|
func (c *ChainArbitrator) SubscribeChannelEvents(
|
||||||
chanPoint wire.OutPoint) (*ChainEventSubscription, error) {
|
chanPoint wire.OutPoint) (*ChainEventSubscription, error) {
|
||||||
|
|
||||||
|
@ -744,6 +744,7 @@ func newServer(listenAddrs []net.Addr, chanDB *channeldb.DB, cc *chainControl,
|
|||||||
},
|
},
|
||||||
Sweeper: s.sweeper,
|
Sweeper: s.sweeper,
|
||||||
SettleInvoice: s.invoices.SettleInvoice,
|
SettleInvoice: s.invoices.SettleInvoice,
|
||||||
|
NotifyClosedChannel: s.channelNotifier.NotifyClosedChannelEvent,
|
||||||
}, chanDB)
|
}, chanDB)
|
||||||
|
|
||||||
s.breachArbiter = newBreachArbiter(&BreachConfig{
|
s.breachArbiter = newBreachArbiter(&BreachConfig{
|
||||||
|
Loading…
Reference in New Issue
Block a user