Correct initialization of antireplay cache

This commit is contained in:
9seconds
2019-09-13 10:14:48 +03:00
parent b280f47731
commit 029245cd16
2 changed files with 5 additions and 10 deletions
+4 -7
View File
@@ -1,9 +1,6 @@
package antireplay package antireplay
import ( import (
"errors"
"fmt"
"github.com/allegro/bigcache" "github.com/allegro/bigcache"
"github.com/9seconds/mtg/config" "github.com/9seconds/mtg/config"
@@ -20,15 +17,15 @@ func Has(data []byte) bool {
return err == nil return err == nil
} }
func Init() error { func Init() {
c, err := bigcache.NewBigCache(bigcache.Config{ c, err := bigcache.NewBigCache(bigcache.Config{
Shards: 1024, Shards: 1024,
LifeWindow: config.C.AntiReplay.EvictionTime, LifeWindow: config.C.AntiReplay.EvictionTime,
Hasher: hasher{}, Hasher: hasher{},
HardMaxCacheSize: config.C.AntiReplay.MaxSize, HardMaxCacheSize: config.C.AntiReplay.MaxSize,
}) })
if err != nil {
panic(err)
}
cache = c cache = c
err = fmt.Errorf("qqq: %w", errors.New("tt"))
return err
} }
+1 -3
View File
@@ -60,9 +60,7 @@ func Proxy() error {
PrintJSONStdout(config.GetURLs()) PrintJSONStdout(config.GetURLs())
if err := antireplay.Init(); err != nil { antireplay.Init()
Fatal(err)
}
if err := stats.Init(ctx); err != nil { if err := stats.Init(ctx); err != nil {
Fatal(err) Fatal(err)
} }