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

lightningnetwork / lnd / 13157733617

05 Feb 2025 12:49PM UTC coverage: 57.712% (-1.1%) from 58.82%
13157733617

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%)

19472 existing lines in 252 files now uncovered.

103634 of 179570 relevant lines covered (57.71%)

24840.31 hits per line

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

67.39
/watchtower/wtclient/stats.go
1
package wtclient
2

3
import (
4
        "fmt"
5
        "sync"
6
)
7

8
// ClientStats is a collection of in-memory statistics of the actions the client
9
// has performed since its creation.
10
type ClientStats struct {
11
        // NumTasksPending is the total number of backups that are pending to
12
        // be acknowledged by all active and exhausted watchtower sessions.
13
        NumTasksPending int
14

15
        // NumTasksAccepted is the total number of backups made to all active
16
        // and exhausted watchtower sessions.
17
        NumTasksAccepted int
18

19
        // NumTasksIneligible is the total number of backups that all active and
20
        // exhausted watchtower sessions have failed to acknowledge.
21
        NumTasksIneligible int
22

23
        // NumSessionsAcquired is the total number of new sessions made to
24
        // watchtowers.
25
        NumSessionsAcquired int
26

27
        // NumSessionsExhausted is the total number of watchtower sessions that
28
        // have been exhausted.
29
        NumSessionsExhausted int
30
}
31

32
// clientStats wraps ClientStats with a mutex so that it's members can be
33
// accessed in a thread safe manner.
34
type clientStats struct {
35
        mu sync.Mutex
36

37
        ClientStats
38
}
39

40
// taskReceived increments the number of backup requests the client has received
41
// from active channels.
42
func (s *clientStats) taskReceived() {
479✔
43
        s.mu.Lock()
479✔
44
        defer s.mu.Unlock()
479✔
45

479✔
46
        s.NumTasksPending++
479✔
47
}
479✔
48

49
// taskAccepted increments the number of tasks that have been assigned to active
50
// session queues, and are awaiting upload to a tower.
51
func (s *clientStats) taskAccepted() {
474✔
52
        s.mu.Lock()
474✔
53
        defer s.mu.Unlock()
474✔
54

474✔
55
        s.NumTasksAccepted++
474✔
56
        s.NumTasksPending--
474✔
57
}
474✔
58

59
// getStatsCopy returns a copy of the ClientStats.
UNCOV
60
func (s *clientStats) getStatsCopy() ClientStats {
×
UNCOV
61
        s.mu.Lock()
×
UNCOV
62
        defer s.mu.Unlock()
×
UNCOV
63

×
UNCOV
64
        return s.ClientStats
×
UNCOV
65
}
×
66

67
// taskIneligible increments the number of tasks that were unable to satisfy the
68
// active session queue's policy. These can potentially be retried later, but
69
// typically this means that the balance created dust outputs, so it may not be
70
// worth backing up at all.
71
func (s *clientStats) taskIneligible() {
5✔
72
        s.mu.Lock()
5✔
73
        defer s.mu.Unlock()
5✔
74

5✔
75
        s.NumTasksIneligible++
5✔
76
}
5✔
77

78
// sessionAcquired increments the number of sessions that have been successfully
79
// negotiated by the client during this execution.
80
func (s *clientStats) sessionAcquired() {
74✔
81
        s.mu.Lock()
74✔
82
        defer s.mu.Unlock()
74✔
83

74✔
84
        s.NumSessionsAcquired++
74✔
85
}
74✔
86

87
// sessionExhausted increments the number of session that have become full as a
88
// result of accepting backup tasks.
89
func (s *clientStats) sessionExhausted() {
44✔
90
        s.mu.Lock()
44✔
91
        defer s.mu.Unlock()
44✔
92

44✔
93
        s.NumSessionsExhausted++
44✔
94
}
44✔
95

96
// String returns a human-readable summary of the client's metrics.
UNCOV
97
func (s *clientStats) String() string {
×
UNCOV
98
        s.mu.Lock()
×
UNCOV
99
        defer s.mu.Unlock()
×
UNCOV
100

×
UNCOV
101
        return fmt.Sprintf("tasks(received=%d accepted=%d ineligible=%d) "+
×
UNCOV
102
                "sessions(acquired=%d exhausted=%d)", s.NumTasksPending,
×
UNCOV
103
                s.NumTasksAccepted, s.NumTasksIneligible, s.NumSessionsAcquired,
×
UNCOV
104
                s.NumSessionsExhausted)
×
UNCOV
105
}
×
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