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

lightningnetwork / lnd / 15155511119

21 May 2025 06:52AM UTC coverage: 57.389% (-11.6%) from 68.996%
15155511119

Pull #9844

github

web-flow
Merge 8658c8597 into c52a6ddeb
Pull Request #9844: Refactor Payment PR 3

346 of 493 new or added lines in 4 files covered. (70.18%)

30172 existing lines in 456 files now uncovered.

95441 of 166305 relevant lines covered (57.39%)

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

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

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

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

51
// Reset clears any stats and sets the lastReset field to now.
52
func (g *builderStats) Reset() {
1✔
53
        g.mu.Lock()
1✔
54
        g.numChannels = 0
1✔
55
        g.numUpdates = 0
1✔
56
        g.numNodes = 0
1✔
57
        g.lastReset = time.Now()
1✔
58
        g.mu.Unlock()
1✔
59
}
1✔
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