mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-02-22 22:25:24 +01:00
rpcsercer+subservercfg: populate autopilot RPC config
This commit is contained in:
parent
28a92185cc
commit
8754635de5
3 changed files with 14 additions and 4 deletions
2
lnd.go
2
lnd.go
|
@ -332,7 +332,7 @@ func lndMain() error {
|
||||||
// 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, atplManager, tlsConf,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
srvrLog.Errorf("unable to start RPC server: %v", err)
|
srvrLog.Errorf("unable to start RPC server: %v", err)
|
||||||
|
|
|
@ -27,6 +27,7 @@ import (
|
||||||
"github.com/coreos/bbolt"
|
"github.com/coreos/bbolt"
|
||||||
"github.com/davecgh/go-spew/spew"
|
"github.com/davecgh/go-spew/spew"
|
||||||
proxy "github.com/grpc-ecosystem/grpc-gateway/runtime"
|
proxy "github.com/grpc-ecosystem/grpc-gateway/runtime"
|
||||||
|
"github.com/lightningnetwork/lnd/autopilot"
|
||||||
"github.com/lightningnetwork/lnd/build"
|
"github.com/lightningnetwork/lnd/build"
|
||||||
"github.com/lightningnetwork/lnd/channeldb"
|
"github.com/lightningnetwork/lnd/channeldb"
|
||||||
"github.com/lightningnetwork/lnd/htlcswitch"
|
"github.com/lightningnetwork/lnd/htlcswitch"
|
||||||
|
@ -392,7 +393,7 @@ var _ lnrpc.LightningServer = (*rpcServer)(nil)
|
||||||
// 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, atpl *autopilot.Manager,
|
||||||
tlsCfg *tls.Config) (*rpcServer, error) {
|
tlsCfg *tls.Config) (*rpcServer, error) {
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -404,7 +405,7 @@ func newRPCServer(s *server, macService *macaroons.Service,
|
||||||
// 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.PopulateDependencies(
|
err := subServerCgs.PopulateDependencies(
|
||||||
s.cc, networkDir, macService,
|
s.cc, networkDir, macService, atpl,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
|
||||||
|
"github.com/lightningnetwork/lnd/autopilot"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc/autopilotrpc"
|
"github.com/lightningnetwork/lnd/lnrpc/autopilotrpc"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc/signrpc"
|
"github.com/lightningnetwork/lnd/lnrpc/signrpc"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc/walletrpc"
|
"github.com/lightningnetwork/lnd/lnrpc/walletrpc"
|
||||||
|
@ -39,7 +40,8 @@ type subRPCServerConfigs struct {
|
||||||
// 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) PopulateDependencies(cc *chainControl,
|
func (s *subRPCServerConfigs) PopulateDependencies(cc *chainControl,
|
||||||
networkDir string, macService *macaroons.Service) error {
|
networkDir string, macService *macaroons.Service,
|
||||||
|
atpl *autopilot.Manager) 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
|
||||||
// that allows us to programmatically inspect its fields.
|
// that allows us to programmatically inspect its fields.
|
||||||
|
@ -97,6 +99,13 @@ func (s *subRPCServerConfigs) PopulateDependencies(cc *chainControl,
|
||||||
reflect.ValueOf(cc.keyRing),
|
reflect.ValueOf(cc.keyRing),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
case *autopilotrpc.Config:
|
||||||
|
subCfgValue := extractReflectValue(cfg)
|
||||||
|
|
||||||
|
subCfgValue.FieldByName("Manager").Set(
|
||||||
|
reflect.ValueOf(atpl),
|
||||||
|
)
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("unknown field: %v, %T", fieldName,
|
return fmt.Errorf("unknown field: %v, %T", fieldName,
|
||||||
cfg)
|
cfg)
|
||||||
|
|
Loading…
Add table
Reference in a new issue