lnd: switch to using the connmgr for listening and persistent conns

This commit revamps the way in bound and outbound connections are
handled within lnd. Instead of manually managing listening goroutines
and also outbound connections, all the duty is now assigned to the
connmgr, a new btcsuite package.

The connmgr now handles accepting inbound (brontide) connections and
communicates with the server to hand off new connections via a
callback. Additionally, any outbound connection attempt is now made
persistent by default, with the assumption that (for right now),
connections are only to be made to peers we wish to make connections
to. Finally, on start-up we now attempt to connection to all/any of our
direct channel counter parties in order to promote the availability of
our channels to the daemon itself and any RPC users.
This commit is contained in:
Olaoluwa Osuntokun
2016-12-14 18:11:31 -08:00
parent 89326423dc
commit bd89a9312d
5 changed files with 279 additions and 125 deletions

7
log.go
View File

@ -4,6 +4,7 @@ import (
"fmt"
"os"
"github.com/btcsuite/btcd/connmgr"
"github.com/btcsuite/btclog"
"github.com/btcsuite/seelog"
"github.com/lightningnetwork/lnd/chainntnfs"
@ -28,6 +29,7 @@ var (
hswcLog = btclog.Disabled
utxnLog = btclog.Disabled
brarLog = btclog.Disabled
cmgrLog = btclog.Disabled
)
// subsystemLoggers maps each subsystem identifier to its associated logger.
@ -43,6 +45,7 @@ var subsystemLoggers = map[string]btclog.Logger{
"HSWC": hswcLog,
"UTXN": utxnLog,
"BRAR": brarLog,
"CMGR": cmgrLog,
}
// useLogger updates the logger references for subsystemID to logger. Invalid
@ -89,6 +92,10 @@ func useLogger(subsystemID string, logger btclog.Logger) {
case "BRAR":
brarLog = logger
case "CMGR":
cmgrLog = logger
connmgr.UseLogger(logger)
}
}