Skip to content

Commit

Permalink
config: add sub-server config parsing logic for the new Router service
Browse files Browse the repository at this point in the history
  • Loading branch information
Roasbeef committed Jan 5, 2019
1 parent 9336f37 commit 7a0a900
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
2 changes: 1 addition & 1 deletion rpcserver.go
Expand Up @@ -405,7 +405,7 @@ func newRPCServer(s *server, macService *macaroons.Service,
// the dependencies they need are properly populated within each sub
// server configuration struct.
err := subServerCgs.PopulateDependencies(
s.cc, networkDir, macService, atpl,
s.cc, networkDir, macService, atpl, s.chanRouter,
)
if err != nil {
return nil, err
Expand Down
26 changes: 25 additions & 1 deletion subrpcserver_config.go
Expand Up @@ -6,9 +6,11 @@ import (

"github.com/lightningnetwork/lnd/autopilot"
"github.com/lightningnetwork/lnd/lnrpc/autopilotrpc"
"github.com/lightningnetwork/lnd/lnrpc/routerpc"
"github.com/lightningnetwork/lnd/lnrpc/signrpc"
"github.com/lightningnetwork/lnd/lnrpc/walletrpc"
"github.com/lightningnetwork/lnd/macaroons"
"github.com/lightningnetwork/lnd/routing"
)

// subRPCServerConfigs is special sub-config in the main configuration that
Expand All @@ -31,6 +33,12 @@ type subRPCServerConfigs struct {
// AutopilotRPC is a sub-RPC server that exposes methods on the running
// autopilot as a gRPC service.
AutopilotRPC *autopilotrpc.Config `group:"autopilotrpc" namespace:"autopilotrpc"`

// RouterRPC is a sub-RPC server the exposes functionality that allows
// clients to send payments on the network, and perform Lightning
// payment related queries such as requests for estimates of off-chain
// fees.
RouterRPC *routerpc.Config `group:"routerpc" namespace:"routerpc"`
}

// PopulateDependencies attempts to iterate through all the sub-server configs
Expand All @@ -41,7 +49,7 @@ type subRPCServerConfigs struct {
// FetchConfig method.
func (s *subRPCServerConfigs) PopulateDependencies(cc *chainControl,
networkDir string, macService *macaroons.Service,
atpl *autopilot.Manager) error {
atpl *autopilot.Manager, chanRouter *routing.ChannelRouter) error {

// First, we'll use reflect to obtain a version of the config struct
// that allows us to programmatically inspect its fields.
Expand Down Expand Up @@ -106,6 +114,22 @@ func (s *subRPCServerConfigs) PopulateDependencies(cc *chainControl,
reflect.ValueOf(atpl),
)

case *routerpc.Config:
subCfgValue := extractReflectValue(cfg)

subCfgValue.FieldByName("NetworkDir").Set(
reflect.ValueOf(networkDir),
)
subCfgValue.FieldByName("ActiveNetParams").Set(
reflect.ValueOf(activeNetParams.Params),
)
subCfgValue.FieldByName("MacService").Set(
reflect.ValueOf(macService),
)
subCfgValue.FieldByName("Router").Set(
reflect.ValueOf(chanRouter),
)

default:
return fmt.Errorf("unknown field: %v, %T", fieldName,
cfg)
Expand Down

0 comments on commit 7a0a900

Please sign in to comment.