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

lightningnetwork / lnd / 13408822928

19 Feb 2025 08:59AM UTC coverage: 41.123% (-17.7%) from 58.794%
13408822928

Pull #9521

github

web-flow
Merge d2f397b3c into 0e8786348
Pull Request #9521: unit: remove GOACC, use Go 1.20 native coverage functionality

92496 of 224923 relevant lines covered (41.12%)

18825.83 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() {
14✔
22
        g.mu.Lock()
14✔
23
        g.numChannels++
14✔
24
        g.mu.Unlock()
14✔
25
}
14✔
26

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

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

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

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

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