mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-17 01:13:45 +00:00
cmd, core: allow --dev to use persistent storage too
This commit is contained in:
parent
53ff59b8a0
commit
ffbb83802c
3 changed files with 29 additions and 20 deletions
|
|
@ -990,16 +990,25 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) {
|
|||
}
|
||||
cfg.Genesis = core.DefaultRinkebyGenesisBlock()
|
||||
case ctx.GlobalBool(DeveloperFlag.Name):
|
||||
faucet, err := ks.NewAccount("")
|
||||
// Create new developer account or reuse existing one
|
||||
var (
|
||||
developer accounts.Account
|
||||
err error
|
||||
)
|
||||
if accs := ks.Accounts(); len(accs) > 0 {
|
||||
developer = ks.Accounts()[0]
|
||||
} else {
|
||||
developer, err = ks.NewAccount("")
|
||||
if err != nil {
|
||||
Fatalf("Failed to create developer account: %v", err)
|
||||
}
|
||||
if err := ks.Unlock(faucet, ""); err != nil {
|
||||
}
|
||||
if err := ks.Unlock(developer, ""); err != nil {
|
||||
Fatalf("Failed to unlock developer account: %v", err)
|
||||
}
|
||||
log.Info("Created developer account", "address", faucet.Address)
|
||||
log.Info("Using developer account", "address", developer.Address)
|
||||
|
||||
cfg.Genesis = core.DefaultDeveloperGenesisBlock(uint64(ctx.GlobalInt(DeveloperPeriodFlag.Name)), faucet.Address)
|
||||
cfg.Genesis = core.DeveloperGenesisBlock(uint64(ctx.GlobalInt(DeveloperPeriodFlag.Name)), developer.Address)
|
||||
if !ctx.GlobalIsSet(GasPriceFlag.Name) {
|
||||
cfg.GasPrice = big.NewInt(1)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ func newTester(t *testing.T, confOverride func(*eth.Config)) *tester {
|
|||
t.Fatalf("failed to create node: %v", err)
|
||||
}
|
||||
ethConf := ð.Config{
|
||||
Genesis: core.DefaultDeveloperGenesisBlock(15, common.Address{}),
|
||||
Genesis: core.DeveloperGenesisBlock(15, common.Address{}),
|
||||
Etherbase: common.HexToAddress(testAddress),
|
||||
PowTest: true,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -342,9 +342,9 @@ func DefaultRinkebyGenesisBlock() *Genesis {
|
|||
}
|
||||
}
|
||||
|
||||
// DefaultDeveloperGenesisBlock returns the 'geth --dev' genesis block. Note, this
|
||||
// must be seeded with the
|
||||
func DefaultDeveloperGenesisBlock(period uint64, faucet common.Address) *Genesis {
|
||||
// DeveloperGenesisBlock returns the 'geth --dev' genesis block. Note, this must
|
||||
// be seeded with the
|
||||
func DeveloperGenesisBlock(period uint64, faucet common.Address) *Genesis {
|
||||
// Override the default period to the user requested one
|
||||
config := *params.AllCliqueProtocolChanges
|
||||
config.Clique.Period = period
|
||||
|
|
@ -353,18 +353,18 @@ func DefaultDeveloperGenesisBlock(period uint64, faucet common.Address) *Genesis
|
|||
return &Genesis{
|
||||
Config: &config,
|
||||
ExtraData: append(append(make([]byte, 32), faucet[:]...), make([]byte, 65)...),
|
||||
GasLimit: 4712388,
|
||||
GasLimit: 6283185,
|
||||
Difficulty: big.NewInt(1),
|
||||
Alloc: map[common.Address]GenesisAccount{
|
||||
common.Address{1}: GenesisAccount{Balance: big.NewInt(1)}, // ECRecover
|
||||
common.Address{2}: GenesisAccount{Balance: big.NewInt(1)}, // SHA256
|
||||
common.Address{3}: GenesisAccount{Balance: big.NewInt(1)}, // RIPEMD
|
||||
common.Address{4}: GenesisAccount{Balance: big.NewInt(1)}, // Identity
|
||||
common.Address{5}: GenesisAccount{Balance: big.NewInt(1)}, // ModExp
|
||||
common.Address{6}: GenesisAccount{Balance: big.NewInt(1)}, // ECAdd
|
||||
common.Address{7}: GenesisAccount{Balance: big.NewInt(1)}, // ECScalarMul
|
||||
common.Address{8}: GenesisAccount{Balance: big.NewInt(1)}, // ECPairing
|
||||
faucet: GenesisAccount{Balance: new(big.Int).Sub(new(big.Int).Lsh(big.NewInt(1), 256), big.NewInt(8))},
|
||||
common.BytesToAddress([]byte{1}): GenesisAccount{Balance: big.NewInt(1)}, // ECRecover
|
||||
common.BytesToAddress([]byte{2}): GenesisAccount{Balance: big.NewInt(1)}, // SHA256
|
||||
common.BytesToAddress([]byte{3}): GenesisAccount{Balance: big.NewInt(1)}, // RIPEMD
|
||||
common.BytesToAddress([]byte{4}): GenesisAccount{Balance: big.NewInt(1)}, // Identity
|
||||
common.BytesToAddress([]byte{5}): GenesisAccount{Balance: big.NewInt(1)}, // ModExp
|
||||
common.BytesToAddress([]byte{6}): GenesisAccount{Balance: big.NewInt(1)}, // ECAdd
|
||||
common.BytesToAddress([]byte{7}): GenesisAccount{Balance: big.NewInt(1)}, // ECScalarMul
|
||||
common.BytesToAddress([]byte{8}): GenesisAccount{Balance: big.NewInt(1)}, // ECPairing
|
||||
faucet: GenesisAccount{Balance: new(big.Int).Sub(new(big.Int).Lsh(big.NewInt(1), 256), big.NewInt(9))},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue