graph: rename routerStats to builderStats

This logic used to be handled by the router. Update to reflect new
owner.
This commit is contained in:
Elle Mouton 2025-02-05 09:54:22 +02:00
parent d757b3bcfc
commit 6169b47d65
No known key found for this signature in database
GPG Key ID: D7D916376026F177
2 changed files with 12 additions and 12 deletions

@ -153,7 +153,7 @@ type Builder struct {
// stats tracks newly processed channels, updates, and node
// announcements over a window of defaultStatInterval.
stats *routerStats
stats *builderStats
quit chan struct{}
wg sync.WaitGroup
@ -171,7 +171,7 @@ func NewBuilder(cfg *Config) (*Builder, error) {
ntfnClientUpdates: make(chan *topologyClientUpdate),
channelEdgeMtx: multimutex.NewMutex[uint64](),
statTicker: ticker.New(defaultStatInterval),
stats: new(routerStats),
stats: new(builderStats),
quit: make(chan struct{}),
}, nil
}

@ -6,9 +6,9 @@ import (
"time"
)
// routerStats is a struct that tracks various updates to the graph and
// builderStats is a struct that tracks various updates to the graph and
// facilitates aggregate logging of the statistics.
type routerStats struct {
type builderStats struct {
numChannels uint32
numUpdates uint32
numNodes uint32
@ -18,28 +18,28 @@ type routerStats struct {
}
// incNumEdges increments the number of discovered edges.
func (g *routerStats) incNumEdgesDiscovered() {
func (g *builderStats) incNumEdgesDiscovered() {
g.mu.Lock()
g.numChannels++
g.mu.Unlock()
}
// incNumUpdates increments the number of channel updates processed.
func (g *routerStats) incNumChannelUpdates() {
func (g *builderStats) incNumChannelUpdates() {
g.mu.Lock()
g.numUpdates++
g.mu.Unlock()
}
// incNumNodeUpdates increments the number of node updates processed.
func (g *routerStats) incNumNodeUpdates() {
func (g *builderStats) incNumNodeUpdates() {
g.mu.Lock()
g.numNodes++
g.mu.Unlock()
}
// Empty returns true if all stats are zero.
func (g *routerStats) Empty() bool {
func (g *builderStats) Empty() bool {
g.mu.RLock()
isEmpty := g.numChannels == 0 &&
g.numUpdates == 0 &&
@ -48,8 +48,8 @@ func (g *routerStats) Empty() bool {
return isEmpty
}
// Reset clears any router stats and sets the lastReset field to now.
func (g *routerStats) Reset() {
// Reset clears any stats and sets the lastReset field to now.
func (g *builderStats) Reset() {
g.mu.Lock()
g.numChannels = 0
g.numUpdates = 0
@ -58,8 +58,8 @@ func (g *routerStats) Reset() {
g.mu.Unlock()
}
// String returns a human-readable description of the router stats.
func (g *routerStats) String() string {
// String returns a human-readable description of the stats.
func (g *builderStats) String() string {
g.mu.RLock()
str := fmt.Sprintf("Processed channels=%d updates=%d nodes=%d in "+
"last %v", g.numChannels, g.numUpdates, g.numNodes,