mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-06-30 10:35:32 +02:00
lnd+rpcserver: allow customized timeout in ConnectPeer
This commit is contained in:
21
rpcserver.go
21
rpcserver.go
@ -1512,8 +1512,25 @@ func (r *rpcServer) ConnectPeer(ctx context.Context,
|
||||
rpcsLog.Debugf("[connectpeer] requested connection to %x@%s",
|
||||
peerAddr.IdentityKey.SerializeCompressed(), peerAddr.Address)
|
||||
|
||||
if err := r.server.ConnectToPeer(peerAddr, in.Perm); err != nil {
|
||||
rpcsLog.Errorf("[connectpeer]: error connecting to peer: %v", err)
|
||||
// By default, we will use the global connection timeout value.
|
||||
timeout := r.cfg.ConnectionTimeout
|
||||
|
||||
// Check if the connection timeout is set. If set, we will use it in our
|
||||
// request.
|
||||
if in.Timeout != 0 {
|
||||
timeout = time.Duration(in.Timeout) * time.Second
|
||||
rpcsLog.Debugf(
|
||||
"[connectpeer] connection timeout is set to %v",
|
||||
timeout,
|
||||
)
|
||||
}
|
||||
|
||||
if err := r.server.ConnectToPeer(peerAddr,
|
||||
in.Perm, timeout); err != nil {
|
||||
|
||||
rpcsLog.Errorf(
|
||||
"[connectpeer]: error connecting to peer: %v", err,
|
||||
)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user