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
2018-10-21 20:36:56 -07:00
committed by Valentine Wallace
parent b0b6151cc1
commit cb26fd8a17
4 changed files with 195 additions and 0 deletions

4
log.go
View File

@ -15,6 +15,7 @@ import (
"github.com/lightningnetwork/lnd/build"
"github.com/lightningnetwork/lnd/chainntnfs"
"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"
@ -80,6 +81,7 @@ var (
wtwrLog = build.NewSubLogger("WTWR", backendLog.Logger)
ntfrLog = build.NewSubLogger("NTFR", backendLog.Logger)
irpcLog = build.NewSubLogger("IRPC", backendLog.Logger)
chnfLog = build.NewSubLogger("CHNF", backendLog.Logger)
)
// Initialize package-global logger variables.
@ -105,6 +107,7 @@ func init() {
watchtower.UseLogger(wtwrLog)
chainrpc.UseLogger(ntfrLog)
invoicesrpc.UseLogger(irpcLog)
channelnotifier.UseLogger(chnfLog)
}
// subsystemLoggers maps each subsystem identifier to its associated logger.
@ -136,6 +139,7 @@ var subsystemLoggers = map[string]btclog.Logger{
"WTWR": wtwrLog,
"NTFR": ntfnLog,
"IRPC": irpcLog,
"CHNF": chnfLog,
}
// initLogRotator initializes the logging rotator to write logs to logFile and