mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
cmd/utils: tryMakeReadOnlyDB should open chaindb only
Signed-off-by: jsvisa <delweng@gmail.com>
This commit is contained in:
parent
509a64ffb9
commit
34f2091e7b
1 changed files with 5 additions and 3 deletions
|
|
@ -2046,7 +2046,7 @@ func SplitTagsFlag(tagsFlag string) map[string]string {
|
|||
}
|
||||
|
||||
// MakeChainDatabase open an LevelDB using the flags passed to the client and will hard crash if it fails.
|
||||
func MakeChainDatabase(ctx *cli.Context, stack *node.Node, readonly bool) ethdb.Database {
|
||||
func MakeChainDatabase(ctx *cli.Context, stack *node.Node, readonly bool, nofreeze bool) ethdb.Database {
|
||||
var (
|
||||
cache = ctx.Int(CacheFlag.Name) * ctx.Int(CacheDatabaseFlag.Name) / 100
|
||||
handles = MakeDatabaseHandles(ctx.Int(FDLimitFlag.Name))
|
||||
|
|
@ -2064,6 +2064,8 @@ func MakeChainDatabase(ctx *cli.Context, stack *node.Node, readonly bool) ethdb.
|
|||
chainDb = remotedb.New(client)
|
||||
case ctx.String(SyncModeFlag.Name) == "light":
|
||||
chainDb, err = stack.OpenDatabase("lightchaindata", cache, handles, "", readonly)
|
||||
case nofreeze:
|
||||
chainDb, err = stack.OpenDatabase("chaindata", cache, handles, "", readonly)
|
||||
default:
|
||||
chainDb, err = stack.OpenDatabaseWithFreezer("chaindata", cache, handles, ctx.String(AncientFlag.Name), "", readonly)
|
||||
}
|
||||
|
|
@ -2082,7 +2084,7 @@ func tryMakeReadOnlyDatabase(ctx *cli.Context, stack *node.Node) ethdb.Database
|
|||
if rawdb.PreexistingDatabase(stack.ResolvePath("chaindata")) == "" {
|
||||
readonly = false
|
||||
}
|
||||
return MakeChainDatabase(ctx, stack, readonly)
|
||||
return MakeChainDatabase(ctx, stack, readonly, true)
|
||||
}
|
||||
|
||||
func IsNetworkPreset(ctx *cli.Context) bool {
|
||||
|
|
@ -2140,7 +2142,7 @@ func MakeGenesis(ctx *cli.Context) *core.Genesis {
|
|||
func MakeChain(ctx *cli.Context, stack *node.Node, readonly bool) (*core.BlockChain, ethdb.Database) {
|
||||
var (
|
||||
gspec = MakeGenesis(ctx)
|
||||
chainDb = MakeChainDatabase(ctx, stack, readonly)
|
||||
chainDb = MakeChainDatabase(ctx, stack, readonly, false)
|
||||
)
|
||||
config, err := core.LoadChainConfig(chainDb, gspec)
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Reference in a new issue