rpcserver+lnrpc: register REST subservers with root server

This commit is contained in:
Oliver Gugger committed 2020-06-04 08:50:44 +02:00
1 parent fe16be5bb8
commit 558d63718b
11 files changed
+224 -4

No files matched your search

+19
View File
@@ -8,6 +8,7 @@ import (
"strconv"
"github.com/btcsuite/btcd/btcec"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/lightningnetwork/lnd/lncfg"
"github.com/lightningnetwork/lnd/lnrpc"
"github.com/lightningnetwork/lnd/lnwire"
@@ -121,6 +122,24 @@ func (c *WatchtowerClient) RegisterWithRootServer(grpcServer *grpc.Server) error
return nil
}
// RegisterWithRestServer will be called by the root REST mux to direct a sub
// RPC server to register itself with the main REST mux server. Until this is
// called, each sub-server won't be able to have requests routed towards it.
//
// NOTE: This is part of the lnrpc.SubServer interface.
func (c *WatchtowerClient) RegisterWithRestServer(ctx context.Context,
mux *runtime.ServeMux, dest string, opts []grpc.DialOption) error {
// We make sure that we register it with the main REST server to ensure
// all our methods are routed properly.
err := RegisterWatchtowerClientHandlerFromEndpoint(ctx, mux, dest, opts)
if err != nil {
return err
}
return nil
}
// isActive returns nil if the watchtower client is initialized so that we can
// process RPC requests.
func (c *WatchtowerClient) isActive() error {