Skip to content

Commit

Permalink
Merge pull request #2744 from gobitfly/NOBIDS/AddMissingPriceInit
Browse files Browse the repository at this point in the history
(NOBIDS) Add missing price Init
  • Loading branch information
recy21 authored Dec 4, 2023
2 parents 034db3e + ec27a8a commit 6714ce4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cmd/notification-collector/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"eth2-exporter/cache"
"eth2-exporter/db"
"eth2-exporter/metrics"
"eth2-exporter/price"
"eth2-exporter/services"
"eth2-exporter/types"
"eth2-exporter/utils"
Expand Down Expand Up @@ -124,6 +125,10 @@ func main() {
}()
}

logrus.Infof("initializing prices...")
price.Init(utils.Config.Chain.ClConfig.DepositChainID, utils.Config.Eth1ErigonEndpoint, utils.Config.Frontend.ClCurrency, utils.Config.Frontend.ElCurrency)
logrus.Infof("...prices initialized")

wg.Wait()

defer db.ReaderDb.Close()
Expand Down
3 changes: 3 additions & 0 deletions price/price.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,9 @@ func setPrice(a, b string, v float64) {
}

func GetPrice(a, b string) float64 {
if didInit < 1 {
logger.Fatal("using GetPrice without calling price.Init once")
}
runOnceWg.Wait()
pricesMu.Lock()
defer pricesMu.Unlock()
Expand Down

0 comments on commit 6714ce4

Please sign in to comment.