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:
5 files changed
+279
-125
No files matched your search
@@ -2,6 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
@@ -9,6 +10,9 @@ import (
|
||||
"strings"
|
||||
|
||||
flags "github.com/btcsuite/go-flags"
|
||||
"github.com/lightningnetwork/lnd/brontide"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
"github.com/roasbeef/btcd/btcec"
|
||||
"github.com/roasbeef/btcutil"
|
||||
)
|
||||
|
||||
@@ -302,3 +306,12 @@ func supportedSubsystems() []string {
|
||||
sort.Strings(subsystems)
|
||||
return subsystems
|
||||
}
|
||||
|
||||
// noiseDial is a factory function which creates a connmgr compliant dialing
|
||||
// function by returning a closure which includes the server's identity key.
|
||||
func noiseDial(idPriv *btcec.PrivateKey) func(net.Addr) (net.Conn, error) {
|
||||
return func(a net.Addr) (net.Conn, error) {
|
||||
lnAddr := a.(*lnwire.NetAddress)
|
||||
return brontide.Dial(idPriv, lnAddr)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user