From 5c1ddfb73805f785991c3276113d0fe38baaa65b Mon Sep 17 00:00:00 2001 From: xinran chen Date: Sun, 25 Jun 2023 23:27:46 +0800 Subject: [PATCH] fix datadir --- config/default.go | 10 +++------- core/startup/startup.go | 6 +++++- example/poa/build.sh | 6 +++--- example/poa/yu_conf/node1/kernel.toml | 2 +- example/poa/yu_conf/node2/kernel.toml | 2 +- example/poa/yu_conf/node3/kernel.toml | 2 +- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/config/default.go b/config/default.go index 3e122aae..218b03fa 100644 --- a/config/default.go +++ b/config/default.go @@ -1,9 +1,5 @@ package config -import ( - "path" -) - func InitDefaultCfg() *KernelConf { cfg := &KernelConf{ RunMode: 0, @@ -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{ diff --git a/core/startup/startup.go b/core/startup/startup.go index 018c529d..fff59ae4 100644 --- a/core/startup/startup.go +++ b/core/startup/startup.go @@ -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 @@ -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) diff --git a/example/poa/build.sh b/example/poa/build.sh index dbd145f7..3efe5f6e 100644 --- a/example/poa/build.sh +++ b/example/poa/build.sh @@ -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 diff --git a/example/poa/yu_conf/node1/kernel.toml b/example/poa/yu_conf/node1/kernel.toml index d2f69cfc..577311cf 100644 --- a/example/poa/yu_conf/node1/kernel.toml +++ b/example/poa/yu_conf/node1/kernel.toml @@ -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" diff --git a/example/poa/yu_conf/node2/kernel.toml b/example/poa/yu_conf/node2/kernel.toml index 716d80de..939295b0 100644 --- a/example/poa/yu_conf/node2/kernel.toml +++ b/example/poa/yu_conf/node2/kernel.toml @@ -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" diff --git a/example/poa/yu_conf/node3/kernel.toml b/example/poa/yu_conf/node3/kernel.toml index fd23967b..dc4c99be 100644 --- a/example/poa/yu_conf/node3/kernel.toml +++ b/example/poa/yu_conf/node3/kernel.toml @@ -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"