cmd/geth: enable dev.alloc in ephemeral dir

Signed-off-by: jsvisa <delweng@gmail.com>
This commit is contained in:
jsvisa 2023-11-02 23:29:07 +08:00
parent 893e6823e8
commit 941cfc5dc0

View file

@ -176,7 +176,7 @@ var (
} }
DeveloperAllocFlag = &cli.PathFlag{ DeveloperAllocFlag = &cli.PathFlag{
Name: "dev.alloc", Name: "dev.alloc",
Usage: "Genesis account allocation file to use in developer mode", Usage: "Genesis account allocation file to use in developer mode (available only if datadir is not enabled)",
TakesFile: true, TakesFile: true,
Category: flags.DevCategory, Category: flags.DevCategory,
} }
@ -1884,10 +1884,10 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
log.Info("Using developer account", "address", developer.Address) log.Info("Using developer account", "address", developer.Address)
var alloc core.GenesisAlloc var alloc core.GenesisAlloc
if allocPath := ctx.Path(DeveloperAllocFlag.Name); allocPath != "" { if ctx.IsSet(DeveloperAllocFlag.Name) && ctx.IsSet(DataDirFlag.Name) {
if ctx.IsSet(DataDirFlag.Name) { Fatalf("The %s flag is conflicted with %s flag, this flag can only be used with an ephemeral data directory", DeveloperAllocFlag.Name, DataDirFlag.Name)
allocPath = stack.ResolvePath(allocPath)
} }
if allocPath := ctx.Path(DeveloperAllocFlag.Name); allocPath != "" {
data, err := os.ReadFile(allocPath) data, err := os.ReadFile(allocPath)
if err != nil { if err != nil {
Fatalf("Failed to read developer genesis alloc file: %v", err) Fatalf("Failed to read developer genesis alloc file: %v", err)