• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

lightningnetwork / lnd / 13707895824

06 Mar 2025 08:49PM UTC coverage: 56.554% (-1.7%) from 58.205%
13707895824

Pull #9458

github

web-flow
Merge d69f7f75d into 7d7e1872c
Pull Request #9458: multi+server.go: add initial permissions for some peers

276 of 549 new or added lines in 10 files covered. (50.27%)

22271 existing lines in 266 files now uncovered.

104853 of 185404 relevant lines covered (56.55%)

24158.62 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

16.67
/lnrpc/wtclientrpc/driver.go
1
package wtclientrpc
2

3
import (
4
        "errors"
5
        "fmt"
6

7
        "github.com/lightningnetwork/lnd/lnrpc"
8
)
9

10
// createNewSubServer is a helper method that will create the new sub server
11
// given the main config dispatcher method. If we're unable to find the config
12
// that is meant for us in the config dispatcher, then we'll exit with an
13
// error.
14
func createNewSubServer(configRegistry lnrpc.SubServerConfigDispatcher) (
UNCOV
15
        *WatchtowerClient, lnrpc.MacaroonPerms, error) {
×
UNCOV
16

×
UNCOV
17
        // We'll attempt to look up the config that we expect, according to our
×
UNCOV
18
        // subServerName name. If we can't find this, then we'll exit with an
×
UNCOV
19
        // error, as we're unable to properly initialize ourselves without this
×
UNCOV
20
        // config.
×
UNCOV
21
        subServerConf, ok := configRegistry.FetchConfig(subServerName)
×
UNCOV
22
        if !ok {
×
23
                return nil, nil, fmt.Errorf("unable to find config for "+
×
24
                        "subserver type %s", subServerName)
×
25
        }
×
26

27
        // Now that we've found an object mapping to our service name, we'll
28
        // ensure that it's the type we need.
UNCOV
29
        config, ok := subServerConf.(*Config)
×
UNCOV
30
        if !ok {
×
31
                return nil, nil, fmt.Errorf("wrong type of config for "+
×
32
                        "subserver %s, expected %T got %T", subServerName,
×
33
                        &Config{}, subServerConf)
×
34
        }
×
35

36
        // Before we try to make the new service instance, we'll perform
37
        // some sanity checks on the arguments to ensure that they're usable.
UNCOV
38
        switch {
×
39
        case config.Resolver == nil:
×
40
                return nil, nil, errors.New("a lncfg.TCPResolver is required")
×
41
        }
42

UNCOV
43
        return New(config)
×
44
}
45

46
func init() {
3✔
47
        subServer := &lnrpc.SubServerDriver{
3✔
48
                SubServerName: subServerName,
3✔
49
                NewGrpcHandler: func() lnrpc.GrpcHandler {
3✔
UNCOV
50
                        return &ServerShell{}
×
UNCOV
51
                },
×
52
        }
53

54
        // If the build tag is active, then we'll register ourselves as a
55
        // sub-RPC server within the global lnrpc package namespace.
56
        if err := lnrpc.RegisterSubServer(subServer); err != nil {
3✔
57
                panic(fmt.Sprintf("failed to register sub server driver "+
×
58
                        "'%s': %v", subServerName, err))
×
59
        }
60
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc