lnd: introduce the ChannelNotifier.

This commit introduces the channel notifier which is a central source
of active, inactive, and closed channel events.

This notifier was originally intended to be used by the `SubscribeChannels`
streaming RPC call, but can be used by any subsystem that needs to be
notified on a channel becoming active, inactive or closed.

It may also be extended in the future to support other types of notifications.
This commit is contained in:
Valentine Wallace authored and Valentine Wallace committed 2019-02-05 18:17:54 -08:00
1 parent b0b6151cc1
commit cb26fd8a17
4 files changed
+195

No files matched your search

+9
View File
@@ -28,6 +28,7 @@ import (
"github.com/lightningnetwork/lnd/autopilot"
"github.com/lightningnetwork/lnd/brontide"
"github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/channelnotifier"
"github.com/lightningnetwork/lnd/contractcourt"
"github.com/lightningnetwork/lnd/discovery"
"github.com/lightningnetwork/lnd/htlcswitch"
@@ -145,6 +146,8 @@ type server struct {
invoices *invoices.InvoiceRegistry
channelNotifier *channelnotifier.ChannelNotifier
witnessBeacon contractcourt.WitnessBeacon
breachArbiter *breachArbiter
@@ -274,6 +277,8 @@ func newServer(listenAddrs []net.Addr, chanDB *channeldb.DB, cc *chainControl,
invoices: invoices.NewRegistry(chanDB, activeNetParams.Params),
channelNotifier: channelnotifier.New(chanDB),
identityPriv: privKey,
nodeSigner: netann.NewNodeSigner(privKey),
@@ -986,6 +991,9 @@ func (s *server) Start() error {
if err := s.cc.chainNotifier.Start(); err != nil {
return err
}
if err := s.channelNotifier.Start(); err != nil {
return err
}
if err := s.sphinx.Start(); err != nil {
return err
}
@@ -1083,6 +1091,7 @@ func (s *server) Stop() error {
s.authGossiper.Stop()
s.chainArb.Stop()
s.sweeper.Stop()
s.channelNotifier.Stop()
s.cc.wallet.Shutdown()
s.cc.chainView.Stop()
s.connMgr.Stop()