rpcsercer+subservercfg: populate autopilot RPC config

This commit is contained in:
Johan T. Halseth committed 2018-12-13 12:33:45 +01:00
1 parent 28a92185cc
commit 8754635de5
3 files changed
+14 -4

No files matched your search

+10 -1
View File
@@ -4,6 +4,7 @@ import (
"fmt"
"reflect"
"github.com/lightningnetwork/lnd/autopilot"
"github.com/lightningnetwork/lnd/lnrpc/autopilotrpc"
"github.com/lightningnetwork/lnd/lnrpc/signrpc"
"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
// FetchConfig method.
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
// that allows us to programmatically inspect its fields.
@@ -97,6 +99,13 @@ func (s *subRPCServerConfigs) PopulateDependencies(cc *chainControl,
reflect.ValueOf(cc.keyRing),
)
case *autopilotrpc.Config:
subCfgValue := extractReflectValue(cfg)
subCfgValue.FieldByName("Manager").Set(
reflect.ValueOf(atpl),
)
default:
return fmt.Errorf("unknown field: %v, %T", fieldName,
cfg)