Spaces:
Paused
Paused
fix TrackUsage and unused import
Browse files- internal/handler/keys.go +6 -0
internal/handler/keys.go
CHANGED
|
@@ -35,6 +35,12 @@ func save() {
|
|
| 35 |
os.WriteFile(p, b, 0644)
|
| 36 |
}
|
| 37 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
func CheckAndTrack(k string, t int) (bool, string) {
|
| 39 |
if k == "free" { return true, "" }
|
| 40 |
s.mu.Lock(); defer s.mu.Unlock()
|
|
|
|
| 35 |
os.WriteFile(p, b, 0644)
|
| 36 |
}
|
| 37 |
|
| 38 |
+
func TrackUsage(k string, t int) {
|
| 39 |
+
if k == "free" { return }
|
| 40 |
+
s.mu.Lock(); defer s.mu.Unlock()
|
| 41 |
+
if kd, ok := s.Keys[k]; ok { kd.Tokens += t; save() }
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
func CheckAndTrack(k string, t int) (bool, string) {
|
| 45 |
if k == "free" { return true, "" }
|
| 46 |
s.mu.Lock(); defer s.mu.Unlock()
|