From 156f0e13abc9e52d67694a872824a83186fec97e Mon Sep 17 00:00:00 2001 From: weiihann Date: Mon, 30 Sep 2024 12:49:27 +0800 Subject: [PATCH] Fix linting --- db/pebble/db.go | 13 +++++-------- node/node.go | 13 ++++++++----- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/db/pebble/db.go b/db/pebble/db.go index f00ab68afc..69db5b7cc6 100644 --- a/db/pebble/db.go +++ b/db/pebble/db.go @@ -22,10 +22,6 @@ const ( // This is also pebble's default value. minCacheSizeMB = 8 - // metricsGatheringInterval specifies the interval to retrieve pebble database - // compaction, io and pause stats to report to the user. - metricsGatheringInterval = 3 * time.Second - // dbNamespace is the namespace for the database metrics dbNamespace = "db" ) @@ -66,7 +62,7 @@ type DB struct { func New(path string, enableMetrics bool, options ...Option) (*DB, error) { opts := &pebble.Options{ - MaxConcurrentCompactions: func() int { return runtime.NumCPU() }, + MaxConcurrentCompactions: runtime.NumCPU, } for _, option := range options { @@ -241,7 +237,7 @@ func (d *DB) enableMetrics() db.DB { return d } -func (d *DB) onCompactionBegin(info pebble.CompactionInfo) { +func (d *DB) onCompactionBegin(info pebble.CompactionInfo) { //nolint:gocritic // Used by pebble's event listener if d.activeComp == 0 { d.compStartTime = time.Now() } @@ -254,7 +250,7 @@ func (d *DB) onCompactionBegin(info pebble.CompactionInfo) { d.activeComp++ } -func (d *DB) onCompactionEnd(info pebble.CompactionInfo) { +func (d *DB) onCompactionEnd(info pebble.CompactionInfo) { //nolint:gocritic // Used by pebble's event listener if d.activeComp == 1 { d.compTime.Add(int64(time.Since(d.compStartTime))) } else if d.activeComp == 0 { @@ -306,7 +302,8 @@ func (d *DB) StartMetricsCollection(ctx context.Context, refresh time.Duration) writeDelayCounts[i%2] = writeDelayCount compTimes[i%2] = compTime - for _, levelMetrics := range metrics.Levels { + for j := range metrics.Levels { + levelMetrics := metrics.Levels[j] nWrite += int64(levelMetrics.BytesCompacted) nWrite += int64(levelMetrics.BytesFlushed) compWrite += int64(levelMetrics.BytesCompacted) diff --git a/node/node.go b/node/node.go index e6dc6fd4e0..6178bf66b0 100644 --- a/node/node.go +++ b/node/node.go @@ -38,10 +38,13 @@ import ( ) const ( - upgraderDelay = 5 * time.Minute - metricsGatheringInterval = 3 * time.Second - githubAPIUrl = "https://api.github.com/repos/NethermindEth/juno/releases/latest" - latestReleaseURL = "https://github.com/NethermindEth/juno/releases/latest" + upgraderDelay = 5 * time.Minute + + // metricsGatheringInterval specifies the interval to retrieve pebble database + // compaction, io and pause stats to report to the user. + dbMetricsGatheringInterval = 3 * time.Second + githubAPIUrl = "https://api.github.com/repos/NethermindEth/juno/releases/latest" + latestReleaseURL = "https://github.com/NethermindEth/juno/releases/latest" ) // Config is the top-level juno configuration. @@ -348,7 +351,7 @@ func (n *Node) Run(ctx context.Context) { wg.Go(func() { defer cancel() - n.db.StartMetricsCollection(ctx, metricsGatheringInterval) + n.db.StartMetricsCollection(ctx, dbMetricsGatheringInterval) }) }