lnrpc/peers: skeleton logic for updateNodeAnnouncement

Basic logic for the endpoint:

- Get the current nodeAnn information
- Calculate modifications
- Apply modifications
- Return changes
This commit is contained in:
positiveblue
2021-12-05 20:24:06 -08:00
parent 5ab0cbd433
commit e4e0935816
17 changed files with 438 additions and 8 deletions

View File

@ -2,6 +2,7 @@ package lnd
import (
"fmt"
"net"
"reflect"
"github.com/btcsuite/btcd/chaincfg"
@ -16,6 +17,7 @@ import (
"github.com/lightningnetwork/lnd/lnrpc/chainrpc"
"github.com/lightningnetwork/lnd/lnrpc/devrpc"
"github.com/lightningnetwork/lnd/lnrpc/invoicesrpc"
"github.com/lightningnetwork/lnd/lnrpc/peersrpc"
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
"github.com/lightningnetwork/lnd/lnrpc/signrpc"
"github.com/lightningnetwork/lnd/lnrpc/walletrpc"
@ -60,6 +62,10 @@ type subRPCServerConfigs struct {
// as a gRPC service.
InvoicesRPC *invoicesrpc.Config `group:"invoicesrpc" namespace:"invoicesrpc"`
// PeersRPC is a sub-RPC server that exposes peer related methods
// as a gRPC service.
PeersRPC *peersrpc.Config `group:"peersrpc" namespace:"peersrpc"`
// 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
@ -107,6 +113,9 @@ func (s *subRPCServerConfigs) PopulateDependencies(cfg *Config,
tcpResolver lncfg.TCPResolver,
genInvoiceFeatures func() *lnwire.FeatureVector,
genAmpInvoiceFeatures func() *lnwire.FeatureVector,
getNodeAnnouncement func() (lnwire.NodeAnnouncement, error),
updateNodeAnnouncement func(modifiers ...netann.NodeAnnModifier) error,
parseAddr func(addr string) (net.Addr, error),
rpcLogger btclog.Logger) error {
// First, we'll use reflect to obtain a version of the config struct
@ -287,6 +296,21 @@ func (s *subRPCServerConfigs) PopulateDependencies(cfg *Config,
reflect.ValueOf(graphDB),
)
case *peersrpc.Config:
subCfgValue := extractReflectValue(subCfg)
subCfgValue.FieldByName("GetNodeAnnouncement").Set(
reflect.ValueOf(getNodeAnnouncement),
)
subCfgValue.FieldByName("ParseAddr").Set(
reflect.ValueOf(parseAddr),
)
subCfgValue.FieldByName("UpdateNodeAnnouncement").Set(
reflect.ValueOf(updateNodeAnnouncement),
)
default:
return fmt.Errorf("unknown field: %v, %T", fieldName,
cfg)