mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
cmd/utils: add --dev.alloc flag
Signed-off-by: jsvisa <delweng@gmail.com>
This commit is contained in:
parent
4e1e37323d
commit
86cfddab5b
1 changed files with 18 additions and 1 deletions
|
|
@ -21,6 +21,7 @@ import (
|
|||
"context"
|
||||
"crypto/ecdsa"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math"
|
||||
|
|
@ -173,6 +174,12 @@ var (
|
|||
Value: 11500000,
|
||||
Category: flags.DevCategory,
|
||||
}
|
||||
DeveloperAllocFlag = &cli.PathFlag{
|
||||
Name: "dev.alloc",
|
||||
Usage: "Genesis account allocation file to use in developer mode",
|
||||
TakesFile: true,
|
||||
Category: flags.DevCategory,
|
||||
}
|
||||
|
||||
IdentityFlag = &cli.StringFlag{
|
||||
Name: "identity",
|
||||
|
|
@ -1876,8 +1883,18 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
|
|||
}
|
||||
log.Info("Using developer account", "address", developer.Address)
|
||||
|
||||
var alloc core.GenesisAlloc
|
||||
if allocPath := ctx.Path(DeveloperAllocFlag.Name); allocPath != "" {
|
||||
data, err := os.ReadFile(allocPath)
|
||||
if err != nil {
|
||||
Fatalf("Failed to read developer genesis alloc file: %v", err)
|
||||
}
|
||||
if err := json.Unmarshal(data, &alloc); err != nil {
|
||||
Fatalf("Failed to parse developer genesis alloc file: %v", err)
|
||||
}
|
||||
}
|
||||
// Create a new developer genesis block or reuse existing one
|
||||
cfg.Genesis = core.DeveloperGenesisBlock(ctx.Uint64(DeveloperGasLimitFlag.Name), developer.Address)
|
||||
cfg.Genesis = core.DeveloperGenesisBlock(ctx.Uint64(DeveloperGasLimitFlag.Name), developer.Address, &alloc)
|
||||
if ctx.IsSet(DataDirFlag.Name) {
|
||||
chaindb := tryMakeReadOnlyDatabase(ctx, stack)
|
||||
if rawdb.ReadCanonicalHash(chaindb, 0) != (common.Hash{}) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue