From 0339d7f6c37095acde288e17ff1d4538b31c8ac9 Mon Sep 17 00:00:00 2001 From: Vuong <3168632+vuon9@users.noreply.github.com> Date: Mon, 22 Nov 2021 05:37:30 +0700 Subject: [PATCH] Fix panic due to using wrong value for key (#285) Signed-off-by: Vuong <3168632+vuon9@users.noreply.github.com> --- cointop/coin.go | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/cointop/coin.go b/cointop/coin.go index 8d2526e..4676101 100644 --- a/cointop/coin.go +++ b/cointop/coin.go @@ -1,8 +1,6 @@ package cointop import ( - "errors" - log "github.com/sirupsen/logrus" ) @@ -106,12 +104,6 @@ func (ct *Cointop) UpdateCoin(coin *Coin) error { return err } - k, found := ct.State.allCoinsSlugMap.Load(coin.Name) - if !found { - log.Debugf("UpdateCoin() could not found coin %s in the slug map", coin.Name) - return errors.New("could not find coin index in allCoinsSlugMap") - } - coin = &Coin{ ID: v.ID, Name: v.Name, @@ -131,7 +123,7 @@ func (ct *Cointop) UpdateCoin(coin *Coin) error { Slug: v.Slug, } - ct.State.allCoinsSlugMap.Store(k, coin) + ct.State.allCoinsSlugMap.Store(coin.Name, coin) return nil }