mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 06:06:44 +00:00
using lightchaindata db dir
This commit is contained in:
parent
4ad808f4dc
commit
658292f934
6 changed files with 26 additions and 15 deletions
|
|
@ -128,7 +128,7 @@ func removeDB(ctx *cli.Context) error {
|
|||
fmt.Println("Removing chaindata...")
|
||||
start := time.Now()
|
||||
|
||||
os.RemoveAll(filepath.Join(ctx.GlobalString(utils.DataDirFlag.Name), "chaindata"))
|
||||
os.RemoveAll(filepath.Join(ctx.GlobalString(utils.DataDirFlag.Name), utils.ChainDbName(ctx)))
|
||||
|
||||
fmt.Printf("Removed in %v\n", time.Since(start))
|
||||
} else {
|
||||
|
|
@ -153,7 +153,7 @@ func upgradeDB(ctx *cli.Context) error {
|
|||
utils.Fatalf("Unable to export chain for reimport %s", err)
|
||||
}
|
||||
chainDb.Close()
|
||||
os.RemoveAll(filepath.Join(ctx.GlobalString(utils.DataDirFlag.Name), "chaindata"))
|
||||
os.RemoveAll(filepath.Join(ctx.GlobalString(utils.DataDirFlag.Name), utils.ChainDbName(ctx)))
|
||||
|
||||
// Import the chain file.
|
||||
chain, chainDb = utils.MakeChain(ctx)
|
||||
|
|
|
|||
|
|
@ -291,7 +291,7 @@ func initGenesis(ctx *cli.Context) error {
|
|||
utils.Fatalf("must supply path to genesis JSON file")
|
||||
}
|
||||
|
||||
chainDb, err := ethdb.NewLDBDatabase(filepath.Join(utils.MustMakeDataDir(ctx), "chaindata"), 0, 0)
|
||||
chainDb, err := ethdb.NewLDBDatabase(filepath.Join(utils.MustMakeDataDir(ctx), utils.ChainDbName(ctx)), 0, 0)
|
||||
if err != nil {
|
||||
utils.Fatalf("could not open database: %v", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -866,15 +866,24 @@ func MustMakeChainConfigFromDb(ctx *cli.Context, db ethdb.Database) *core.ChainC
|
|||
return &core.ChainConfig{HomesteadBlock: homesteadBlockNo}
|
||||
}
|
||||
|
||||
func ChainDbName(ctx *cli.Context) string {
|
||||
if ctx.GlobalBool(LightModeFlag.Name) {
|
||||
return "lightchaindata"
|
||||
} else {
|
||||
return "chaindata"
|
||||
}
|
||||
}
|
||||
|
||||
// MakeChainDatabase open an LevelDB using the flags passed to the client and will hard crash if it fails.
|
||||
func MakeChainDatabase(ctx *cli.Context) ethdb.Database {
|
||||
var (
|
||||
datadir = MustMakeDataDir(ctx)
|
||||
cache = ctx.GlobalInt(CacheFlag.Name)
|
||||
handles = MakeDatabaseHandles()
|
||||
name = ChainDbName(ctx)
|
||||
)
|
||||
|
||||
chainDb, err := ethdb.NewLDBDatabase(filepath.Join(datadir, "chaindata"), cache, handles)
|
||||
chainDb, err := ethdb.NewLDBDatabase(filepath.Join(datadir, name), cache, handles)
|
||||
if err != nil {
|
||||
Fatalf("Could not open database: %v", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -157,7 +157,7 @@ func (s *FullNodeService) AddLesServer(ls LesServer) {
|
|||
// New creates a new FullNodeService object (including the
|
||||
// initialisation of the common Ethereum object)
|
||||
func New(ctx *node.ServiceContext, config *Config) (*FullNodeService, error) {
|
||||
chainDb, dappDb, err := CreateDBs(ctx, config)
|
||||
chainDb, dappDb, err := CreateDBs(ctx, config, "chaindata")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
@ -257,9 +257,9 @@ func New(ctx *node.ServiceContext, config *Config) (*FullNodeService, error) {
|
|||
}
|
||||
|
||||
// CreateDBs creates the chain and dapp databases for an Ethereum service
|
||||
func CreateDBs(ctx *node.ServiceContext, config *Config) (chainDb, dappDb ethdb.Database, err error) {
|
||||
func CreateDBs(ctx *node.ServiceContext, config *Config, name string) (chainDb, dappDb ethdb.Database, err error) {
|
||||
// Open the chain database and perform any upgrades needed
|
||||
chainDb, err = ctx.OpenDatabase("chaindata", config.DatabaseCache, config.DatabaseHandles)
|
||||
chainDb, err = ctx.OpenDatabase(name, config.DatabaseCache, config.DatabaseHandles)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ var OpenFileLimit = 64
|
|||
var cacheRatio = map[string]float64{
|
||||
"dapp": 0.0,
|
||||
"chaindata": 1.0,
|
||||
"lightchaindata": 1.0,
|
||||
}
|
||||
|
||||
// handleRatio specifies how the total alloted file descriptors is distributed
|
||||
|
|
@ -48,6 +49,7 @@ var cacheRatio = map[string]float64{
|
|||
var handleRatio = map[string]float64{
|
||||
"dapp": 0.0,
|
||||
"chaindata": 1.0,
|
||||
"lightchaindata": 1.0,
|
||||
}
|
||||
|
||||
type LDBDatabase struct {
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ type LightNodeService struct {
|
|||
}
|
||||
|
||||
func New(ctx *node.ServiceContext, config *eth.Config) (*LightNodeService, error) {
|
||||
chainDb, dappDb, err := eth.CreateDBs(ctx, config)
|
||||
chainDb, dappDb, err := eth.CreateDBs(ctx, config, "lightchaindata")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue