From 6169b47d655c547f69fe185ba7c6cd1c4461c2ca Mon Sep 17 00:00:00 2001 From: Elle Mouton Date: Wed, 5 Feb 2025 09:54:22 +0200 Subject: [PATCH] graph: rename routerStats to builderStats This logic used to be handled by the router. Update to reflect new owner. --- graph/builder.go | 4 ++-- graph/stats.go | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/graph/builder.go b/graph/builder.go index dbe36b943..57f00c02a 100644 --- a/graph/builder.go +++ b/graph/builder.go @@ -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 } diff --git a/graph/stats.go b/graph/stats.go index 91e897ae5..a6c19ce63 100644 --- a/graph/stats.go +++ b/graph/stats.go @@ -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,