From 3bf5496fce5079bb8dcb2ad4bbf4efcd662858f2 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 2 Apr 2026 18:50:29 +0100 Subject: [PATCH] ax(batch): fix abbreviated names in comment examples and locals MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit h→hash/histogram, e→miningError, a/b→current/previous, n→count, user/pass→username/password, passMatch→passwordMatch in comment examples and auth.go locals. Co-Authored-By: Charon --- pkg/mining/auth.go | 11 +++++------ pkg/mining/errors.go | 4 ++-- pkg/mining/metrics.go | 6 +++--- pkg/mining/miner.go | 10 +++++----- 4 files changed, 15 insertions(+), 16 deletions(-) diff --git a/pkg/mining/auth.go b/pkg/mining/auth.go index 8e00015..6169102 100644 --- a/pkg/mining/auth.go +++ b/pkg/mining/auth.go @@ -179,16 +179,15 @@ func (digestAuth *DigestAuth) validateDigest(c *gin.Context, authHeader string) // valid := digestAuth.validateBasic(c, c.GetHeader("Authorization")) func (digestAuth *DigestAuth) validateBasic(c *gin.Context, authHeader string) bool { // Gin has built-in basic auth, but we do manual validation for consistency - user, pass, ok := c.Request.BasicAuth() + username, password, ok := c.Request.BasicAuth() if !ok { return false } - // Constant-time comparison to prevent timing attacks - userMatch := subtle.ConstantTimeCompare([]byte(user), []byte(digestAuth.config.Username)) == 1 - passMatch := subtle.ConstantTimeCompare([]byte(pass), []byte(digestAuth.config.Password)) == 1 + userMatch := subtle.ConstantTimeCompare([]byte(username), []byte(digestAuth.config.Username)) == 1 + passwordMatch := subtle.ConstantTimeCompare([]byte(password), []byte(digestAuth.config.Password)) == 1 - return userMatch && passMatch + return userMatch && passwordMatch } // nonce := digestAuth.generateNonce() // 32-char hex string, cryptographically random @@ -253,7 +252,7 @@ func parseDigestParams(header string) map[string]string { return params } -// h := md5Hash("user:realm:pass") // "5f4dcc3b5aa765d61d8327deb882cf99" +// hash := md5Hash("user:realm:pass") // "5f4dcc3b5aa765d61d8327deb882cf99" func md5Hash(input string) string { digest := md5.Sum([]byte(input)) return hex.EncodeToString(digest[:]) diff --git a/pkg/mining/errors.go b/pkg/mining/errors.go index fa137cb..13fc9ff 100644 --- a/pkg/mining/errors.go +++ b/pkg/mining/errors.go @@ -26,8 +26,8 @@ const ( ErrCodeInternalError = "INTERNAL_ERROR" ) -// e := &MiningError{Code: ErrCodeStartFailed, Message: "failed to start xmrig", HTTPStatus: 500} -// e.WithCause(err).WithSuggestion("check logs") +// miningError := &MiningError{Code: ErrCodeStartFailed, Message: "failed to start xmrig", HTTPStatus: 500} +// miningError.WithCause(err).WithSuggestion("check logs") type MiningError struct { Code string // Machine-readable error code Message string // Human-readable message diff --git a/pkg/mining/metrics.go b/pkg/mining/metrics.go index 83a3d43..150b431 100644 --- a/pkg/mining/metrics.go +++ b/pkg/mining/metrics.go @@ -34,15 +34,15 @@ type Metrics struct { P2PConnectionsTotal atomic.Int64 } -// h := mining.NewLatencyHistogram(1000) -// h.Record(42 * time.Millisecond) +// histogram := mining.NewLatencyHistogram(1000) +// histogram.Record(42 * time.Millisecond) type LatencyHistogram struct { mutex sync.Mutex samples []time.Duration maxSize int } -// h := mining.NewLatencyHistogram(1000) // retain up to 1000 latency samples +// histogram := mining.NewLatencyHistogram(1000) // retain up to 1000 latency samples func NewLatencyHistogram(maxSize int) *LatencyHistogram { return &LatencyHistogram{ samples: make([]time.Duration, 0, maxSize), diff --git a/pkg/mining/miner.go b/pkg/mining/miner.go index 144ca2b..93e5061 100644 --- a/pkg/mining/miner.go +++ b/pkg/mining/miner.go @@ -285,9 +285,9 @@ func (b *BaseMiner) InstallFromURL(url string) error { return nil } -// a := parseVersion("6.24.0") // [6, 24, 0] -// b := parseVersion("5.0.1") // [5, 0, 1] -// if compareVersions(a, b) > 0 { /* a is newer */ } +// current := parseVersion("6.24.0") // [6, 24, 0] +// previous := parseVersion("5.0.1") // [5, 0, 1] +// if compareVersions(current, previous) > 0 { /* current is newer */ } func parseVersion(versionString string) []int { parts := strings.Split(versionString, ".") intParts := make([]int, len(parts)) @@ -435,14 +435,14 @@ func (b *BaseMiner) AddHashratePoint(point HashratePoint) { b.HashrateHistory = append(b.HashrateHistory, point) } -// n := miner.GetHighResHistoryLength() // 0..30 points (last 5 min at 10s resolution) +// count := miner.GetHighResHistoryLength() // 0..30 points (last 5 min at 10s resolution) func (b *BaseMiner) GetHighResHistoryLength() int { b.mutex.RLock() defer b.mutex.RUnlock() return len(b.HashrateHistory) } -// n := miner.GetLowResHistoryLength() // 0..1440 points (last 24h at 1min resolution) +// count := miner.GetLowResHistoryLength() // 0..1440 points (last 24h at 1min resolution) func (b *BaseMiner) GetLowResHistoryLength() int { b.mutex.RLock() defer b.mutex.RUnlock()