multi: use timeout field in dialer
This commit is contained in:
7 files changed
+35
-29
No files matched your search
@@ -14,6 +14,7 @@ import (
|
||||
"github.com/lightningnetwork/lnd/keychain"
|
||||
"github.com/lightningnetwork/lnd/lnwallet"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
"github.com/lightningnetwork/lnd/tor"
|
||||
"github.com/lightningnetwork/lnd/watchtower/wtdb"
|
||||
"github.com/lightningnetwork/lnd/watchtower/wtpolicy"
|
||||
"github.com/lightningnetwork/lnd/watchtower/wtserver"
|
||||
@@ -137,7 +138,7 @@ type Config struct {
|
||||
|
||||
// Dial connects to an addr using the specified net and returns the
|
||||
// connection object.
|
||||
Dial Dial
|
||||
Dial tor.DialFunc
|
||||
|
||||
// AuthDialer establishes a brontide connection over an onion or clear
|
||||
// network.
|
||||
|
||||
@@ -16,6 +16,7 @@ import (
|
||||
"github.com/lightningnetwork/lnd/keychain"
|
||||
"github.com/lightningnetwork/lnd/lnwallet"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
"github.com/lightningnetwork/lnd/tor"
|
||||
"github.com/lightningnetwork/lnd/watchtower/blob"
|
||||
"github.com/lightningnetwork/lnd/watchtower/wtclient"
|
||||
"github.com/lightningnetwork/lnd/watchtower/wtdb"
|
||||
@@ -84,7 +85,9 @@ func newMockNet(cb func(wtserver.Peer)) *mockNet {
|
||||
}
|
||||
}
|
||||
|
||||
func (m *mockNet) Dial(network string, address string) (net.Conn, error) {
|
||||
func (m *mockNet) Dial(network string, address string,
|
||||
timeout time.Duration) (net.Conn, error) {
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
@@ -100,8 +103,9 @@ func (m *mockNet) ResolveTCPAddr(network string, address string) (*net.TCPAddr,
|
||||
panic("not implemented")
|
||||
}
|
||||
|
||||
func (m *mockNet) AuthDial(local keychain.SingleKeyECDH, netAddr *lnwire.NetAddress,
|
||||
dialer func(string, string) (net.Conn, error)) (wtserver.Peer, error) {
|
||||
func (m *mockNet) AuthDial(local keychain.SingleKeyECDH,
|
||||
netAddr *lnwire.NetAddress,
|
||||
dialer tor.DialFunc) (wtserver.Peer, error) {
|
||||
|
||||
localPk := local.PubKey()
|
||||
localAddr := &net.TCPAddr{
|
||||
@@ -433,10 +437,8 @@ func newHarness(t *testing.T, cfg harnessCfg) *testHarness {
|
||||
clientDB := wtmock.NewClientDB()
|
||||
|
||||
clientCfg := &wtclient.Config{
|
||||
Signer: signer,
|
||||
Dial: func(string, string) (net.Conn, error) {
|
||||
return nil, nil
|
||||
},
|
||||
Signer: signer,
|
||||
Dial: mockNet.Dial,
|
||||
DB: clientDB,
|
||||
AuthDial: mockNet.AuthDial,
|
||||
SecretKeyRing: wtmock.NewSecretKeyRing(),
|
||||
|
||||
@@ -4,9 +4,9 @@ import (
|
||||
"net"
|
||||
|
||||
"github.com/btcsuite/btcd/btcec"
|
||||
"github.com/lightningnetwork/lnd/brontide"
|
||||
"github.com/lightningnetwork/lnd/keychain"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
"github.com/lightningnetwork/lnd/tor"
|
||||
"github.com/lightningnetwork/lnd/watchtower/wtdb"
|
||||
"github.com/lightningnetwork/lnd/watchtower/wtserver"
|
||||
)
|
||||
@@ -95,22 +95,12 @@ type DB interface {
|
||||
AckUpdate(id *wtdb.SessionID, seqNum, lastApplied uint16) error
|
||||
}
|
||||
|
||||
// Dial connects to an addr using the specified net and returns the connection
|
||||
// object.
|
||||
type Dial func(net, addr string) (net.Conn, error)
|
||||
|
||||
// AuthDialer connects to a remote node using an authenticated transport, such as
|
||||
// brontide. The dialer argument is used to specify a resolver, which allows
|
||||
// this method to be used over Tor or clear net connections.
|
||||
type AuthDialer func(localKey keychain.SingleKeyECDH, netAddr *lnwire.NetAddress,
|
||||
dialer func(string, string) (net.Conn, error)) (wtserver.Peer, error)
|
||||
|
||||
// AuthDial is the watchtower client's default method of dialing.
|
||||
func AuthDial(localKey keychain.SingleKeyECDH, netAddr *lnwire.NetAddress,
|
||||
dialer func(string, string) (net.Conn, error)) (wtserver.Peer, error) {
|
||||
|
||||
return brontide.Dial(localKey, netAddr, dialer)
|
||||
}
|
||||
type AuthDialer func(localKey keychain.SingleKeyECDH,
|
||||
netAddr *lnwire.NetAddress,
|
||||
dialer tor.DialFunc) (wtserver.Peer, error)
|
||||
|
||||
// ECDHKeyRing abstracts the ability to derive shared ECDH keys given a
|
||||
// description of the derivation path of a private key.
|
||||
|
||||
Reference in new issue
Block a user