@@ -130,7 +130,7 @@ func (p *rpcProxy) Start() error {
130
130
131
131
// Setup the connection to lnd.
132
132
host , _ , tlsPath , _ := p .cfg .lndConnectParams ()
133
- p .lndConn , err = dialLnd ( host , tlsPath )
133
+ p .lndConn , err = dialBackend ( "lnd" , host , tlsPath )
134
134
if err != nil {
135
135
return fmt .Errorf ("could not dial lnd: %v" , err )
136
136
}
@@ -336,21 +336,20 @@ func (p *rpcProxy) basicAuthToMacaroon(ctx context.Context,
336
336
return metadata .NewIncomingContext (ctx , md ), nil
337
337
}
338
338
339
- // dialLnd connects to lnd through the given address and uses the given TLS
340
- // certificate to authenticate the connection.
341
- func dialLnd (dialAddr , tlsCertPath string ) (* grpc.ClientConn , error ) {
342
-
339
+ // dialBackend connects to a gRPC backend through the given address and uses the
340
+ // given TLS certificate to authenticate the connection.
341
+ func dialBackend (name , dialAddr , tlsCertPath string ) (* grpc.ClientConn , error ) {
343
342
var opts []grpc.DialOption
344
343
tlsConfig , err := credentials .NewClientTLSFromFile (tlsCertPath , "" )
345
344
if err != nil {
346
- return nil , fmt .Errorf ("could not read lnd TLS cert %s: %v" ,
347
- tlsCertPath , err )
345
+ return nil , fmt .Errorf ("could not read %s TLS cert %s: %v" ,
346
+ name , tlsCertPath , err )
348
347
}
349
348
350
349
opts = append (
351
350
opts ,
352
351
353
- // From the grpxProxy doc: This codec is *crucial* to the
352
+ // From the grpcProxy doc: This codec is *crucial* to the
354
353
// functioning of the proxy.
355
354
grpc .WithCodec (grpcProxy .Codec ()), // nolint
356
355
grpc .WithTransportCredentials (tlsConfig ),
@@ -361,10 +360,11 @@ func dialLnd(dialAddr, tlsCertPath string) (*grpc.ClientConn, error) {
361
360
}),
362
361
)
363
362
364
- log .Infof ("Dialing lnd gRPC server at %s" , dialAddr )
363
+ log .Infof ("Dialing %s gRPC server at %s" , name , dialAddr )
365
364
cc , err := grpc .Dial (dialAddr , opts ... )
366
365
if err != nil {
367
- return nil , fmt .Errorf ("failed dialing backend: %v" , err )
366
+ return nil , fmt .Errorf ("failed dialing %s backend: %v" , name ,
367
+ err )
368
368
}
369
369
return cc , nil
370
370
}
0 commit comments