lnd+rpc: fix linter errors

This commit is contained in:
Olaoluwa Osuntokun 2018-11-02 15:41:38 -07:00
parent 35b4b35eae
commit a8ac3cfe7d
No known key found for this signature in database
GPG Key ID: CE58F7F8E20FD9A2
4 changed files with 15 additions and 13 deletions

@ -221,7 +221,7 @@ type config struct {
Tor *torConfig `group:"Tor" namespace:"tor"` Tor *torConfig `group:"Tor" namespace:"tor"`
SubRpcServers *subRpcServerConfigs `group:"subrpc"` SubRPCServers *subRPCServerConfigs `group:"subrpc"`
Hodl *hodl.Config `group:"hodl" namespace:"hodl"` Hodl *hodl.Config `group:"hodl" namespace:"hodl"`
@ -298,7 +298,7 @@ func loadConfig() (*config, error) {
}, },
MaxPendingChannels: defaultMaxPendingChannels, MaxPendingChannels: defaultMaxPendingChannels,
NoSeedBackup: defaultNoSeedBackup, NoSeedBackup: defaultNoSeedBackup,
SubRpcServers: &subRpcServerConfigs{ SubRPCServers: &subRPCServerConfigs{
SignRPC: &signrpc.Config{}, SignRPC: &signrpc.Config{},
}, },
Autopilot: &autoPilotConfig{ Autopilot: &autoPilotConfig{

2
lnd.go

@ -315,7 +315,7 @@ func lndMain() error {
// Initialize, and register our implementation of the gRPC interface // Initialize, and register our implementation of the gRPC interface
// exported by the rpcServer. // exported by the rpcServer.
rpcServer, err := newRPCServer( rpcServer, err := newRPCServer(
server, macaroonService, cfg.SubRpcServers, serverOpts, server, macaroonService, cfg.SubRPCServers, serverOpts,
proxyOpts, tlsConf, proxyOpts, tlsConf,
) )
if err != nil { if err != nil {

@ -383,7 +383,7 @@ var _ lnrpc.LightningServer = (*rpcServer)(nil)
// base level options passed to the grPC server. This typically includes things // base level options passed to the grPC server. This typically includes things
// like requiring TLS, etc. // like requiring TLS, etc.
func newRPCServer(s *server, macService *macaroons.Service, func newRPCServer(s *server, macService *macaroons.Service,
subServerCgs *subRpcServerConfigs, serverOpts []grpc.ServerOption, subServerCgs *subRPCServerConfigs, serverOpts []grpc.ServerOption,
restServerOpts []grpc.DialOption, restServerOpts []grpc.DialOption,
tlsCfg *tls.Config) (*rpcServer, error) { 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 // Before we create any of the sub-servers, we need to ensure that all
// the dependencies they need are properly populated within each sub // the dependencies they need are properly populated within each sub
// server configuration struct. // server configuration struct.
err := subServerCgs.PopulateDependancies( err := subServerCgs.PopulateDependencies(
s.cc, networkDir, macService, s.cc, networkDir, macService,
) )
if err != nil { 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 // Finally, with all the pre-set up complete, we can create the main
// gRPC server, and register the main lnrpc server along side. // gRPC server, and register the main lnrpc server along side.
grpcServer := grpc.NewServer(serverOpts...) grpcServer := grpc.NewServer(serverOpts...)
rootRpcServer := &rpcServer{ rootRPCServer := &rpcServer{
restServerOpts: restServerOpts, restServerOpts: restServerOpts,
subServers: subServers, subServers: subServers,
tlsCfg: tlsCfg, tlsCfg: tlsCfg,
@ -462,7 +462,7 @@ func newRPCServer(s *server, macService *macaroons.Service,
server: s, server: s,
quit: make(chan struct{}, 1), 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 // Now the main RPC server has been registered, we'll iterate through
// all the sub-RPC servers and register them to ensure that requests // 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. // Start launches any helper goroutines required for the rpcServer to function.
@ -572,6 +572,8 @@ func (r *rpcServer) Stop() error {
subServer.Name()) subServer.Name())
if err := subServer.Stop(); err != nil { if err := subServer.Stop(); err != nil {
rpcsLog.Errorf("unable to stop sub-server %v: %v",
subServer.Name(), err)
continue continue
} }
} }

@ -8,25 +8,25 @@ import (
"github.com/lightningnetwork/lnd/macaroons" "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 // houses the configuration for the optional sub-servers. These sub-RPC servers
// are meant to house experimental new features that may eventually make it // 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 // 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 // this struct to allow the main RPC server to create and manipulate the
// sub-RPC servers in a generalized manner. // 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 // SignRPC is a sub-RPC server that exposes signing of arbitrary inputs
// as a gRPC service. // as a gRPC service.
SignRPC *signrpc.Config `group:"signrpc" namespace:"signrpc"` 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 // within this struct, and populate the items it requires based on the main
// configuration file, and the chain control. // configuration file, and the chain control.
// //
// NOTE: This MUST be called before any callers are permitted to execute the // NOTE: This MUST be called before any callers are permitted to execute the
// FetchConfig method. // FetchConfig method.
func (s *subRpcServerConfigs) PopulateDependancies(cc *chainControl, func (s *subRPCServerConfigs) PopulateDependencies(cc *chainControl,
networkDir string, macService *macaroons.Service) error { networkDir string, macService *macaroons.Service) error {
// First, we'll use reflect to obtain a version of the config struct // 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. // subServerName name, then false will be returned for the second parameter.
// //
// NOTE: Part of the lnrpc.SubServerConfigDispatcher interface. // 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 // First, we'll use reflect to obtain a version of the config struct
// that allows us to programmatically inspect its fields. // that allows us to programmatically inspect its fields.
selfVal := extractReflectValue(s) selfVal := extractReflectValue(s)