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

lightningnetwork / lnd / 14358372723

09 Apr 2025 01:26PM UTC coverage: 56.696% (-12.3%) from 69.037%
14358372723

Pull #9696

github

web-flow
Merge e2837e400 into 867d27d68
Pull Request #9696: Add `development_guidelines.md` for both human and machine

107055 of 188823 relevant lines covered (56.7%)

22721.56 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) (
15
        *WatchtowerClient, lnrpc.MacaroonPerms, error) {
×
16

×
17
        // We'll attempt to look up the config that we expect, according to our
×
18
        // subServerName name. If we can't find this, then we'll exit with an
×
19
        // error, as we're unable to properly initialize ourselves without this
×
20
        // config.
×
21
        subServerConf, ok := configRegistry.FetchConfig(subServerName)
×
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.
29
        config, ok := subServerConf.(*Config)
×
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.
38
        switch {
×
39
        case config.Resolver == nil:
×
40
                return nil, nil, errors.New("a lncfg.TCPResolver is required")
×
41
        }
42

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✔
50
                        return &ServerShell{}
×
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