Skip to content

Commit

Permalink
fix datadir (#66)
Browse files Browse the repository at this point in the history
Co-authored-by: xinran chen <[email protected]>
  • Loading branch information
Lawliet-Chan and xinran chen committed Jun 25, 2023
1 parent 2be2c11 commit 01a03c0
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
10 changes: 3 additions & 7 deletions config/default.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
package config

import (
"path"
)

func InitDefaultCfg() *KernelConf {
cfg := &KernelConf{
RunMode: 0,
Expand All @@ -26,14 +22,14 @@ func InitDefaultCfg() *KernelConf {
NodeKeyFile: "",
}
cfg.KVDB = KVconf{
KvType: "bolt",
Path: path.Join(cfg.DataDir, "yu.db"),
KvType: "pebble",
Path: "yu.db",
Hosts: nil,
}
cfg.BlockChain = BlockchainConf{
ChainDB: SqlDbConf{
SqlDbType: "sqlite",
Dsn: path.Join(cfg.DataDir, "chain.db"),
Dsn: "chain.db",
},
}
cfg.Txpool = TxpoolConf{
Expand Down
6 changes: 5 additions & 1 deletion core/startup/startup.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ import (
"github.com/yu-org/yu/infra/p2p"
"github.com/yu-org/yu/infra/storage/kv"
"github.com/yu-org/yu/utils/codec"
"path"
)

var (
kernelCfg = &config.KernelConf{}
kernelCfg = new(config.KernelConf)

Chain types.IBlockChain
TxnDB types.ItxDB
Expand Down Expand Up @@ -54,6 +55,9 @@ func InitKernel(tripodInstances ...interface{}) *kernel.Kernel {
codec.GlobalCodec = &codec.RlpCodec{}
gin.SetMode(gin.ReleaseMode)

// init database
kernelCfg.KVDB.Path = path.Join(kernelCfg.DataDir, kernelCfg.KVDB.Path)
kernelCfg.BlockChain.ChainDB.Dsn = path.Join(kernelCfg.DataDir, kernelCfg.BlockChain.ChainDB.Dsn)
kvdb, err := kv.NewKvdb(&kernelCfg.KVDB)
if err != nil {
logrus.Fatal("init kvdb error: ", err)
Expand Down
6 changes: 3 additions & 3 deletions example/poa/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ cp $node2_cfg_path $node2_path/$yu_cfg_path
mv poa $node3_path/
cp $node3_cfg_path $node3_path/$yu_cfg_path

rm -rf $node1_path/*.*
rm -rf $node2_path/*.*
rm -rf $node3_path/*.*
rm -rf $node1_path/yu
rm -rf $node2_path/yu
rm -rf $node3_path/yu
2 changes: 1 addition & 1 deletion example/poa/yu_conf/node1/kernel.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ node_key_rand_seed = 1

[kvdb]
kv_type = "pebble"
path = "./yu.db"
path = "yu.db"

[block_chain.chain_db]
sql_db_type = "sqlite"
Expand Down
2 changes: 1 addition & 1 deletion example/poa/yu_conf/node2/kernel.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ node_key_type = 1

[kvdb]
kv_type = "pebble"
path = "./yu.db"
path = "yu.db"

[block_chain.chain_db]
sql_db_type = "sqlite"
Expand Down
2 changes: 1 addition & 1 deletion example/poa/yu_conf/node3/kernel.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ node_key_type = 1

[kvdb]
kv_type = "pebble"
path = "./yu.db"
path = "yu.db"

[block_chain.chain_db]
sql_db_type = "sqlite"
Expand Down

0 comments on commit 01a03c0

Please sign in to comment.