Skip to content

Commit

Permalink
config add dataDir
Browse files Browse the repository at this point in the history
  • Loading branch information
zhiquan911 committed Jun 21, 2019
1 parent 20e0246 commit 91cdc96
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,7 @@ ServerAPI = "http://127.0.0.1:18090"
isTestNet = false
# feeLimit, the maximum energy is 1000000000
feeLimit = 10000000
# Cache data file directory, default = "", current directory: ./data
dataDir = ""

```
23 changes: 20 additions & 3 deletions tron/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ type WalletConfig struct {
FeeLimit int64
//FeeMini 智能合约最小能量消耗起,1 Energy = 10 SUN
FeeMini int64
//数据目录
DataDir string
}

//NewConfig Create config instance
Expand Down Expand Up @@ -197,9 +199,9 @@ feeLimit = 10000000
`

//创建目录
file.MkdirAll(c.dbPath)
file.MkdirAll(c.backupDir)
file.MkdirAll(c.keyDir)
//file.MkdirAll(c.dbPath)
//file.MkdirAll(c.backupDir)
//file.MkdirAll(c.keyDir)

return &c
}
Expand Down Expand Up @@ -248,3 +250,18 @@ func (wc *WalletConfig) InitConfig() {
}

}

//创建文件夹
func (wc *WalletConfig) makeDataDir() {

if len(wc.DataDir) == 0 {
//默认路径当前文件夹./data
wc.DataDir = "data"
}

//本地数据库文件路径
wc.dbPath = filepath.Join(wc.DataDir, strings.ToLower(wc.Symbol), "db")

//创建目录
file.MkdirAll(wc.dbPath)
}
4 changes: 4 additions & 0 deletions tron/config_load.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,9 @@ func (wm *WalletManager) LoadAssetsConfig(c config.Configer) error {
//}

wm.WalletClient = NewClient(wm.Config.ServerAPI, "", false)
wm.Config.DataDir = c.String("dataDir")

//数据文件夹
wm.Config.makeDataDir()
return nil
}

0 comments on commit 91cdc96

Please sign in to comment.