Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Level 2 glog for price fetching logic #541

Merged
merged 1 commit into from
Feb 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions routes/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ func (fes *APIServer) GetBlockchainDotComExchangeRate() (_exchangeRate float64,
glog.Errorf("GetBlockchainDotComExchangeRate: Problem getting max from list of float64s: %v", err)
return 0, err
}
glog.Infof("Blockchain exchange rate: %v %v", blockchainDotComExchangeRate, exchangeRatesFetched)
glog.V(2).Infof("Blockchain exchange rate: %v %v", blockchainDotComExchangeRate, exchangeRatesFetched)
if fes.backendServer != nil && fes.backendServer.GetStatsdClient() != nil {
if err = fes.backendServer.GetStatsdClient().Gauge("BLOCKCHAIN_LAST_TRADE_PRICE", blockchainDotComExchangeRate, []string{}, 1); err != nil {
glog.Errorf("GetBlockchainDotComExchangeRate: Error logging Last Trade Price of %f to datadog: %v", blockchainDotComExchangeRate, err)
Expand Down Expand Up @@ -243,18 +243,18 @@ func (fes *APIServer) GetCoinbaseExchangeRate() (_exchangeRate float64, _err err

// UpdateUSDCentsToDeSoExchangeRate updates app state's USD Cents per DeSo value
func (fes *APIServer) UpdateUSDCentsToDeSoExchangeRate() {
glog.Infof("Refreshing exchange rate...")
glog.V(2).Info("Refreshing exchange rate...")

// Fetch price from blockchain.com
blockchainDotComPrice, err := fes.GetBlockchainDotComExchangeRate()
glog.Infof("Blockchain.com price (USD cents): %v", blockchainDotComPrice)
glog.V(2).Infof("Blockchain.com price (USD cents): %v", blockchainDotComPrice)
if err != nil {
glog.Errorf("UpdateUSDCentsToDeSoExchangeRate: Error fetching exchange rate from blockchain.com: %v", err)
}

// Fetch price from coinbase
coinbasePrice, err := fes.GetCoinbaseExchangeRate()
glog.Infof("Coinbase price (USD Cents): %v", coinbasePrice)
glog.V(2).Infof("Coinbase price (USD Cents): %v", coinbasePrice)
if err != nil {
glog.Errorf("UpdateUSDCentsToDeSoExchangeRate: Error fetching exchange rate from coinbase: %v", err)
}
Expand Down Expand Up @@ -283,29 +283,29 @@ func (fes *APIServer) UpdateUSDCentsToDeSoExchangeRate() {
fes.UsdCentsPerDeSoExchangeRate = maxPrice
}

glog.Infof("Final exchange rate: %v", fes.UsdCentsPerDeSoExchangeRate)
glog.V(2).Infof("Final exchange rate: %v", fes.UsdCentsPerDeSoExchangeRate)
}

func (fes *APIServer) UpdateUSDToBTCPrice() {
glog.Info("Refreshing USD to BTC exchange rate")
glog.V(2).Info("Refreshing USD to BTC exchange rate")
btcExchangeRate, err := GetUSDToBTCPrice()
if err != nil {
glog.Errorf("Error getting BTC price: %v", err)
return
}
fes.UsdCentsPerBitCoinExchangeRate = btcExchangeRate * 100
glog.Infof("New USD to BTC exchange rate: %f", fes.UsdCentsPerBitCoinExchangeRate/100)
glog.V(2).Infof("New USD to BTC exchange rate: %f", fes.UsdCentsPerBitCoinExchangeRate/100)
}

func (fes *APIServer) UpdateUSDToETHPrice() {
glog.Info("Refreshing USD to ETH exchange rate")
glog.V(2).Info("Refreshing USD to ETH exchange rate")
ethExchangeRate, err := apis.GetUSDToETHPrice()
if err != nil {
glog.Errorf("Error getting ETH price: %v", err)
return
}
fes.UsdCentsPerETHExchangeRate = uint64(ethExchangeRate * 100)
glog.Infof("New USD to ETH exchange rate: %f", float64(fes.UsdCentsPerETHExchangeRate)/100)
glog.V(2).Infof("New USD to ETH exchange rate: %f", float64(fes.UsdCentsPerETHExchangeRate)/100)
}

// getMaxPriceFromHistoryAndCull removes elements that are outside of the lookback window and return the max price
Expand Down
Loading