From 029245cd169ff484944661845921970d5d355004 Mon Sep 17 00:00:00 2001 From: 9seconds Date: Fri, 13 Sep 2019 10:14:48 +0300 Subject: [PATCH] Correct initialization of antireplay cache --- antireplay/cache.go | 11 ++++------- cli/proxy.go | 4 +--- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/antireplay/cache.go b/antireplay/cache.go index 359cb39..219d2d2 100644 --- a/antireplay/cache.go +++ b/antireplay/cache.go @@ -1,9 +1,6 @@ package antireplay import ( - "errors" - "fmt" - "github.com/allegro/bigcache" "github.com/9seconds/mtg/config" @@ -20,15 +17,15 @@ func Has(data []byte) bool { return err == nil } -func Init() error { +func Init() { c, err := bigcache.NewBigCache(bigcache.Config{ Shards: 1024, LifeWindow: config.C.AntiReplay.EvictionTime, Hasher: hasher{}, HardMaxCacheSize: config.C.AntiReplay.MaxSize, }) + if err != nil { + panic(err) + } cache = c - err = fmt.Errorf("qqq: %w", errors.New("tt")) - - return err } diff --git a/cli/proxy.go b/cli/proxy.go index ec8df0b..bd78832 100644 --- a/cli/proxy.go +++ b/cli/proxy.go @@ -60,9 +60,7 @@ func Proxy() error { PrintJSONStdout(config.GetURLs()) - if err := antireplay.Init(); err != nil { - Fatal(err) - } + antireplay.Init() if err := stats.Init(ctx); err != nil { Fatal(err) }