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

lightningnetwork / lnd / 12986279612

27 Jan 2025 09:51AM UTC coverage: 57.652% (-1.1%) from 58.788%
12986279612

Pull #9447

github

yyforyongyu
sweep: rename methods for clarity

We now rename "third party" to "unknown" as the inputs can be spent via
an older sweeping tx, a third party (anchor), or a remote party (pin).
In fee bumper we don't have the info to distinguish the above cases, and
leave them to be further handled by the sweeper as it has more context.
Pull Request #9447: sweep: start tracking input spending status in the fee bumper

83 of 87 new or added lines in 2 files covered. (95.4%)

19578 existing lines in 256 files now uncovered.

103448 of 179434 relevant lines covered (57.65%)

24884.58 hits per line

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

29.03
/lncfg/cluster.go
1
package lncfg
2

3
import (
4
        "context"
5
        "fmt"
6
        "os"
7

8
        "github.com/lightningnetwork/lnd/cluster"
9
)
10

11
const (
12
        // DefaultEtcdElectionPrefix is used as election prefix if none is provided
13
        // through the config.
14
        DefaultEtcdElectionPrefix = "/leader/"
15
)
16

17
// Cluster holds configuration for clustered LND.
18
type Cluster struct {
19
        EnableLeaderElection bool `long:"enable-leader-election" description:"Enables leader election if set."`
20

21
        LeaderElector string `long:"leader-elector" choice:"etcd" description:"Leader elector to use. Valid values: \"etcd\"."`
22

23
        EtcdElectionPrefix string `long:"etcd-election-prefix" description:"Election key prefix when using etcd leader elector."`
24

25
        ID string `long:"id" description:"Identifier for this node inside the cluster (used in leader election). Defaults to the hostname."`
26

27
        LeaderSessionTTL int `long:"leader-session-ttl" description:"The TTL in seconds to use for the leader election session."`
28
}
29

30
// DefaultCluster creates and returns a new default DB config.
31
func DefaultCluster() *Cluster {
1✔
32
        hostname, _ := os.Hostname()
1✔
33
        return &Cluster{
1✔
34
                LeaderElector:      cluster.EtcdLeaderElector,
1✔
35
                EtcdElectionPrefix: DefaultEtcdElectionPrefix,
1✔
36
                LeaderSessionTTL:   90,
1✔
37
                ID:                 hostname,
1✔
38
        }
1✔
39
}
1✔
40

41
// MakeLeaderElector is a helper method to construct the concrete leader elector
42
// based on the current configuration.
43
func (c *Cluster) MakeLeaderElector(electionCtx context.Context, db *DB) (
44
        cluster.LeaderElector, error) {
×
45

×
46
        if c.LeaderElector == cluster.EtcdLeaderElector {
×
47
                return cluster.MakeLeaderElector(
×
48
                        electionCtx, c.LeaderElector, c.ID,
×
49
                        c.EtcdElectionPrefix, c.LeaderSessionTTL, db.Etcd,
×
50
                )
×
51
        }
×
52

53
        return nil, fmt.Errorf("unsupported leader elector")
×
54
}
55

56
// Validate validates the Cluster config.
UNCOV
57
func (c *Cluster) Validate() error {
×
UNCOV
58
        if !c.EnableLeaderElection {
×
UNCOV
59
                return nil
×
UNCOV
60
        }
×
61

62
        switch c.LeaderElector {
×
63
        case cluster.EtcdLeaderElector:
×
64
                if c.EtcdElectionPrefix == "" {
×
65
                        return fmt.Errorf("etcd-election-prefix must be set")
×
66
                }
×
67
                return nil
×
68

69
        default:
×
70
                return fmt.Errorf("unknown leader elector, valid values are: "+
×
71
                        "\"%v\"", cluster.EtcdLeaderElector)
×
72
        }
73
}
74

75
// Compile-time constraint to ensure Workers implements the Validator interface.
76
var _ Validator = (*Cluster)(nil)
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