From a8ac3cfe7dd0f560bd0a4acb5ab341f4f7cd7b40 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Fri, 2 Nov 2018 15:41:38 -0700 Subject: [PATCH] lnd+rpc: fix linter errors --- config.go | 4 ++-- lnd.go | 2 +- rpcserver.go | 12 +++++++----- subrpcserver_config.go | 10 +++++----- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/config.go b/config.go index 4bd06c707..050d4a2b2 100644 --- a/config.go +++ b/config.go @@ -221,7 +221,7 @@ type config struct { Tor *torConfig `group:"Tor" namespace:"tor"` - SubRpcServers *subRpcServerConfigs `group:"subrpc"` + SubRPCServers *subRPCServerConfigs `group:"subrpc"` Hodl *hodl.Config `group:"hodl" namespace:"hodl"` @@ -298,7 +298,7 @@ func loadConfig() (*config, error) { }, MaxPendingChannels: defaultMaxPendingChannels, NoSeedBackup: defaultNoSeedBackup, - SubRpcServers: &subRpcServerConfigs{ + SubRPCServers: &subRPCServerConfigs{ SignRPC: &signrpc.Config{}, }, Autopilot: &autoPilotConfig{ diff --git a/lnd.go b/lnd.go index 6b5dd1884..b9f0a59ab 100644 --- a/lnd.go +++ b/lnd.go @@ -315,7 +315,7 @@ func lndMain() error { // Initialize, and register our implementation of the gRPC interface // exported by the rpcServer. rpcServer, err := newRPCServer( - server, macaroonService, cfg.SubRpcServers, serverOpts, + server, macaroonService, cfg.SubRPCServers, serverOpts, proxyOpts, tlsConf, ) if err != nil { diff --git a/rpcserver.go b/rpcserver.go index ccdcfc15c..73125c6c6 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -383,7 +383,7 @@ var _ lnrpc.LightningServer = (*rpcServer)(nil) // base level options passed to the grPC server. This typically includes things // like requiring TLS, etc. func newRPCServer(s *server, macService *macaroons.Service, - subServerCgs *subRpcServerConfigs, serverOpts []grpc.ServerOption, + subServerCgs *subRPCServerConfigs, serverOpts []grpc.ServerOption, restServerOpts []grpc.DialOption, tlsCfg *tls.Config) (*rpcServer, error) { @@ -395,7 +395,7 @@ func newRPCServer(s *server, macService *macaroons.Service, // Before we create any of the sub-servers, we need to ensure that all // the dependencies they need are properly populated within each sub // server configuration struct. - err := subServerCgs.PopulateDependancies( + err := subServerCgs.PopulateDependencies( s.cc, networkDir, macService, ) if err != nil { @@ -454,7 +454,7 @@ func newRPCServer(s *server, macService *macaroons.Service, // Finally, with all the pre-set up complete, we can create the main // gRPC server, and register the main lnrpc server along side. grpcServer := grpc.NewServer(serverOpts...) - rootRpcServer := &rpcServer{ + rootRPCServer := &rpcServer{ restServerOpts: restServerOpts, subServers: subServers, tlsCfg: tlsCfg, @@ -462,7 +462,7 @@ func newRPCServer(s *server, macService *macaroons.Service, server: s, quit: make(chan struct{}, 1), } - lnrpc.RegisterLightningServer(grpcServer, rootRpcServer) + lnrpc.RegisterLightningServer(grpcServer, rootRPCServer) // Now the main RPC server has been registered, we'll iterate through // all the sub-RPC servers and register them to ensure that requests @@ -476,7 +476,7 @@ func newRPCServer(s *server, macService *macaroons.Service, } } - return rootRpcServer, nil + return rootRPCServer, nil } // Start launches any helper goroutines required for the rpcServer to function. @@ -572,6 +572,8 @@ func (r *rpcServer) Stop() error { subServer.Name()) if err := subServer.Stop(); err != nil { + rpcsLog.Errorf("unable to stop sub-server %v: %v", + subServer.Name(), err) continue } } diff --git a/subrpcserver_config.go b/subrpcserver_config.go index da8f195c3..0abb969b4 100644 --- a/subrpcserver_config.go +++ b/subrpcserver_config.go @@ -8,25 +8,25 @@ import ( "github.com/lightningnetwork/lnd/macaroons" ) -// subRpcServerConfigs is special sub-config in the main configuration that +// subRPCServerConfigs is special sub-config in the main configuration that // houses the configuration for the optional sub-servers. These sub-RPC servers // are meant to house experimental new features that may eventually make it // into the main RPC server that lnd exposes. Special methods are present on // this struct to allow the main RPC server to create and manipulate the // sub-RPC servers in a generalized manner. -type subRpcServerConfigs struct { +type subRPCServerConfigs struct { // SignRPC is a sub-RPC server that exposes signing of arbitrary inputs // as a gRPC service. SignRPC *signrpc.Config `group:"signrpc" namespace:"signrpc"` } -// PopulateDependancies attempts to iterate through all the sub-server configs +// PopulateDependencies attempts to iterate through all the sub-server configs // within this struct, and populate the items it requires based on the main // configuration file, and the chain control. // // NOTE: This MUST be called before any callers are permitted to execute the // FetchConfig method. -func (s *subRpcServerConfigs) PopulateDependancies(cc *chainControl, +func (s *subRPCServerConfigs) PopulateDependencies(cc *chainControl, networkDir string, macService *macaroons.Service) error { // First, we'll use reflect to obtain a version of the config struct @@ -80,7 +80,7 @@ func (s *subRpcServerConfigs) PopulateDependancies(cc *chainControl, // subServerName name, then false will be returned for the second parameter. // // NOTE: Part of the lnrpc.SubServerConfigDispatcher interface. -func (s *subRpcServerConfigs) FetchConfig(subServerName string) (interface{}, bool) { +func (s *subRPCServerConfigs) FetchConfig(subServerName string) (interface{}, bool) { // First, we'll use reflect to obtain a version of the config struct // that allows us to programmatically inspect its fields. selfVal := extractReflectValue(s)