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

lightningnetwork / lnd / 12645066077

07 Jan 2025 04:08AM UTC coverage: 48.341% (-10.3%) from 58.598%
12645066077

Pull #9232

github

Abdulkbk
chanbackup: test archiving chan backups
Pull Request #9232: chanbackup: archive old channel backup files

45 of 61 new or added lines in 3 files covered. (73.77%)

29050 existing lines in 443 files now uncovered.

98430 of 203615 relevant lines covered (48.34%)

0.51 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
// routerStats is a struct that tracks various updates to the graph and
10
// facilitates aggregate logging of the statistics.
11
type routerStats 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 *routerStats) 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 *routerStats) 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 *routerStats) 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 *routerStats) 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 router stats and sets the lastReset field to now.
52
func (g *routerStats) 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 router stats.
UNCOV
62
func (g *routerStats) 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

© 2026 Coveralls, Inc