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

lightningnetwork / lnd / 16012627499

01 Jul 2025 11:49PM UTC coverage: 67.305% (-0.3%) from 67.561%
16012627499

Pull #10012

github

web-flow
Merge b870fb76f into 538723e33
Pull Request #10012: multi: prevent goroutine leak in brontide

9 of 24 new or added lines in 2 files covered. (37.5%)

1090 existing lines in 35 files now uncovered.

134600 of 199985 relevant lines covered (67.31%)

21889.96 hits per line

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

79.49
/graph/stats.go
1
package graph
2

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

9
// builderStats is a struct that tracks various updates to the graph and
10
// facilitates aggregate logging of the statistics.
11
type builderStats struct {
12
        numChannels uint32
13
        numUpdates  uint32
14
        numNodes    uint32
15
        lastReset   time.Time
16

17
        mu sync.RWMutex
18
}
19

20
// incNumEdges increments the number of discovered edges.
21
func (g *builderStats) incNumEdgesDiscovered() {
15✔
22
        g.mu.Lock()
15✔
23
        g.numChannels++
15✔
24
        g.mu.Unlock()
15✔
25
}
15✔
26

27
// incNumUpdates increments the number of channel updates processed.
28
func (g *builderStats) incNumChannelUpdates() {
6✔
29
        g.mu.Lock()
6✔
30
        g.numUpdates++
6✔
31
        g.mu.Unlock()
6✔
32
}
6✔
33

34
// incNumNodeUpdates increments the number of node updates processed.
35
func (g *builderStats) incNumNodeUpdates() {
7✔
36
        g.mu.Lock()
7✔
37
        g.numNodes++
7✔
38
        g.mu.Unlock()
7✔
39
}
7✔
40

41
// Empty returns true if all stats are zero.
42
func (g *builderStats) Empty() bool {
97✔
43
        g.mu.RLock()
97✔
44
        isEmpty := g.numChannels == 0 &&
97✔
45
                g.numUpdates == 0 &&
97✔
46
                g.numNodes == 0
97✔
47
        g.mu.RUnlock()
97✔
48
        return isEmpty
97✔
49
}
97✔
50

51
// Reset clears any stats and sets the lastReset field to now.
52
func (g *builderStats) Reset() {
21✔
53
        g.mu.Lock()
21✔
54
        g.numChannels = 0
21✔
55
        g.numUpdates = 0
21✔
56
        g.numNodes = 0
21✔
57
        g.lastReset = time.Now()
21✔
58
        g.mu.Unlock()
21✔
59
}
21✔
60

61
// String returns a human-readable description of the stats.
UNCOV
62
func (g *builderStats) String() string {
×
UNCOV
63
        g.mu.RLock()
×
UNCOV
64
        str := fmt.Sprintf("Processed channels=%d updates=%d nodes=%d in "+
×
UNCOV
65
                "last %v", g.numChannels, g.numUpdates, g.numNodes,
×
UNCOV
66
                time.Since(g.lastReset))
×
UNCOV
67
        g.mu.RUnlock()
×
UNCOV
68
        return str
×
UNCOV
69
}
×
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