From 1592721fd79aa34e7ece8e32e82954848dd05f9d Mon Sep 17 00:00:00 2001 From: mojocn Date: Fri, 17 Jan 2025 11:51:52 +0800 Subject: [PATCH] fix type error --- internal/node/app.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/internal/node/app.go b/internal/node/app.go index 8c7f89c..aaca9b1 100644 --- a/internal/node/app.go +++ b/internal/node/app.go @@ -107,13 +107,12 @@ func (app *App) loopPush() { } func (app *App) trafficInc(uid string, byteN int64) { - kb := math.Ceil(float64(byteN) / float64(1024)) + kbInt64 := int64(math.Ceil(float64(byteN) / float64(1024))) value, ok := app.trafficUserKB.Load(uid) - if !ok { - app.trafficUserKB.Store(uid, kb) - return + if ok { + kbInt64 += value.(int64) } - app.trafficUserKB.Store(uid, value.(int64)+int64(kb)) + app.trafficUserKB.Store(uid, kbInt64) } func (app *App) stat() *AppStat { @@ -169,7 +168,7 @@ func (app *App) PushNode() { } req.Header.Set("Content-Type", "application/json") req.Header.Set("Authorization", app.cfg.RegisterToken) - client := &http.Client{Timeout: 10 * time.Second} + client := &http.Client{Timeout: 10 * time.Second} resp, err := client.Do(req) if err != nil { log.Println("Error registering:", err)