cmd: remove deprecated lightchaindata db (#30527)

This commit is contained in:
Daniel Liu 2025-03-07 13:18:49 +08:00
parent 825a3cbb77
commit 2f349da4bf
3 changed files with 17 additions and 23 deletions

View file

@ -206,7 +206,7 @@ func initGenesis(ctx *cli.Context) error {
stack, _ := makeFullNode(ctx) stack, _ := makeFullNode(ctx)
defer stack.Close() defer stack.Close()
for _, name := range []string{"chaindata", "lightchaindata"} { name := "chaindata"
chaindb, err := stack.OpenDatabase(name, 0, 0, "", false) chaindb, err := stack.OpenDatabase(name, 0, 0, "", false)
if err != nil { if err != nil {
utils.Fatalf("Failed to open database: %v", err) utils.Fatalf("Failed to open database: %v", err)
@ -217,7 +217,6 @@ func initGenesis(ctx *cli.Context) error {
} }
chaindb.Close() chaindb.Close()
log.Info("Successfully wrote genesis state", "database", name, "hash", hash) log.Info("Successfully wrote genesis state", "database", name, "hash", hash)
}
return nil return nil
} }

View file

@ -148,14 +148,13 @@ WARNING: This is a low-level operation which may cause database corruption!`,
func removeDB(ctx *cli.Context) error { func removeDB(ctx *cli.Context) error {
stack, _ := makeConfigNode(ctx) stack, _ := makeConfigNode(ctx)
for _, name := range []string{"chaindata", "lightchaindata"} { name := "chaindata"
dbdir := stack.ResolvePath(name) dbdir := stack.ResolvePath(name)
if common.FileExist(dbdir) { if common.FileExist(dbdir) {
confirmAndRemoveDB(dbdir, name) confirmAndRemoveDB(dbdir, name)
} else { } else {
log.Info("Database doesn't exist, skipping", "path", dbdir) log.Info("Database doesn't exist, skipping", "path", dbdir)
} }
}
return nil return nil
} }

View file

@ -1565,11 +1565,7 @@ func MakeChainDatabase(ctx *cli.Context, stack *node.Node, readonly bool) ethdb.
cache = ctx.Int(CacheFlag.Name) * ctx.Int(CacheDatabaseFlag.Name) / 100 cache = ctx.Int(CacheFlag.Name) * ctx.Int(CacheDatabaseFlag.Name) / 100
handles = MakeDatabaseHandles(ctx.Int(FDLimitFlag.Name)) handles = MakeDatabaseHandles(ctx.Int(FDLimitFlag.Name))
) )
name := "chaindata" chainDb, err := stack.OpenDatabase("chaindata", cache, handles, "", readonly)
if ctx.String(SyncModeFlag.Name) == "light" {
name = "lightchaindata"
}
chainDb, err := stack.OpenDatabase(name, cache, handles, "", readonly)
if err != nil { if err != nil {
Fatalf("Could not open database: %v", err) Fatalf("Could not open database: %v", err)
} }