Skip to content

Commit

Permalink
fixed no such file or directory
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinBeBoy committed Jan 7, 2024
1 parent 778120c commit efb9ecd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ func loadConfig() (*config, error) {
}

cfg := defaultConfig(defaultHomeDir)

defaultCfg := defaultConfig(defaultHomeDir)

// Pre-parse the command line options to see if an alternative config file
Expand Down
9 changes: 6 additions & 3 deletions libwallet/assets_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,9 @@ func (mgr *AssetsManager) cleanDeletedWallets() {
rootDir := filepath.Join(mgr.params.RootDir, dirName, wType.ToStringLower())
files, err := os.ReadDir(rootDir)
if err != nil {
if os.IsNotExist(err) {
continue
}
log.Errorf("can't read %s root wallet type: %v", wType, err)
return
}
Expand Down Expand Up @@ -865,13 +868,13 @@ func (mgr *AssetsManager) CalculateTotalAssetsBalance() (map[utils.AssetType]sha

func (mgr *AssetsManager) CalculateAssetsUSDBalance(balances map[utils.AssetType]sharedW.AssetAmount) (map[utils.AssetType]float64, error) {
if !mgr.ExchangeRateFetchingEnabled() {
return nil, fmt.Errorf("USD exchange rate is disabled")
return nil, fmt.Errorf("the USD exchange rate is disabled")
}

usdBalance := func(bal sharedW.AssetAmount, market string) (float64, error) {
rate := mgr.RateSource.GetTicker(market)
if rate == nil || rate.LastTradePrice <= 0 {
return 0, fmt.Errorf("No rate information available")
return 0, fmt.Errorf("no rate information available")
}

return bal.MulF64(rate.LastTradePrice).ToCoin(), nil
Expand All @@ -881,7 +884,7 @@ func (mgr *AssetsManager) CalculateAssetsUSDBalance(balances map[utils.AssetType
for assetType, balance := range balances {
marketValue, exist := values.AssetExchangeMarketValue[assetType]
if !exist {
return nil, fmt.Errorf("Unsupported asset type: %s", assetType)
return nil, fmt.Errorf("unsupported asset type: %s", assetType)
}
usdBal, err := usdBalance(balance, marketValue)
if err != nil {
Expand Down
7 changes: 4 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package main

import (
"encoding/json"
"fmt"
"net/http"
_ "net/http/pprof"
"os"
"path/filepath"
"time"

"gioui.org/app"
Expand Down Expand Up @@ -33,6 +33,8 @@ var (

func main() {
cfg, err := loadConfig()
d, _ := json.Marshal(cfg)
fmt.Println("DEBUG: PRINT DATA ==>", string(d))
if err != nil {
fmt.Printf("Error: %s\n", err.Error())
return
Expand Down Expand Up @@ -65,8 +67,7 @@ func main() {
buildDate = time.Now()
}

logDir := filepath.Join(cfg.LogDir, string(cfg.net))
assetsManager, err := libwallet.NewAssetsManager(cfg.HomeDir, logDir, cfg.net)
assetsManager, err := libwallet.NewAssetsManager(cfg.HomeDir, cfg.LogDir, cfg.net)
if err != nil {
log.Errorf("init assetsManager error: %v", err)
return
Expand Down

0 comments on commit efb9ecd

Please sign in to comment.