lnrpc/signrpc: add lnrpc.SubServerDriver for signrpc

In this commit, we create a lnrpc.SubServerDriver for signrpc. Note that
this file will only have its init() method executed if the proper build
flag is on. As a result, only if the build flag is set, will the RPC
server be registered, and visible at the packge lnrpc level for the root
server to manipulate.
This commit is contained in:
Olaoluwa Osuntokun committed 2018-11-28 20:57:03 -08:00
1 parent b7757683b2
commit 8971931aa3
4 files changed
+15 -14

No files matched your search

+7 -2
View File
@@ -34,10 +34,13 @@ func createNewSubServer(configRegistry lnrpc.SubServerConfigDispatcher) (
&Config{}, signServerConf)
}
// Before we try to make the new signer service instance, we'll perform
// some sanity checks on the arguments to ensure that they're useable.
switch {
// If the macaroon service is set (we should use macaroons), then
// ensure that we know where to look for them, or create them if not
// found.
switch {
case config.MacService != nil && config.NetworkDir == "":
return nil, nil, fmt.Errorf("NetworkDir must be set to create " +
"Signrpc")
@@ -52,7 +55,9 @@ func createNewSubServer(configRegistry lnrpc.SubServerConfigDispatcher) (
func init() {
subServer := &lnrpc.SubServerDriver{
SubServerName: subServerName,
New: func(c lnrpc.SubServerConfigDispatcher) (lnrpc.SubServer, lnrpc.MacaroonPerms, error) {
New: func(c lnrpc.SubServerConfigDispatcher) (
lnrpc.SubServer, lnrpc.MacaroonPerms, error) {
return createNewSubServer(c)
},
}