@@ -18,7 +18,9 @@ package main
1818
1919import (
2020 "bytes"
21+ "encoding/json"
2122 "fmt"
23+ "io/ioutil"
2224 "math/big"
2325 "math/rand"
2426 "time"
@@ -135,3 +137,53 @@ func (w *wizard) makeGenesis() {
135137 // All done, store the genesis and flush to disk
136138 w.conf.genesis = genesis
137139}
140+
141+ // manageGenesis permits the modification of chain configuration parameters in
142+ // a genesis config and the export of the entire genesis spec.
143+ func (w *wizard) manageGenesis() {
144+ // Figure out whether to modify or export the genesis
145+ fmt.Println()
146+ fmt.Println(" 1. Modify existing fork rules")
147+ fmt.Println(" 2. Export genesis configuration")
148+
149+ choice := w.read()
150+ switch {
151+ case choice == "1":
152+ // Fork rule updating requested, iterate over each fork
153+ fmt.Println()
154+ fmt.Printf("Which block should Homestead come into effect? (default = %v)\n", w.conf.genesis.Config.HomesteadBlock)
155+ w.conf.genesis.Config.HomesteadBlock = w.readDefaultBigInt(w.conf.genesis.Config.HomesteadBlock)
156+
157+ fmt.Println()
158+ fmt.Printf("Which block should EIP150 come into effect? (default = %v)\n", w.conf.genesis.Config.EIP150Block)
159+ w.conf.genesis.Config.EIP150Block = w.readDefaultBigInt(w.conf.genesis.Config.EIP150Block)
160+
161+ fmt.Println()
162+ fmt.Printf("Which block should EIP155 come into effect? (default = %v)\n", w.conf.genesis.Config.EIP155Block)
163+ w.conf.genesis.Config.EIP155Block = w.readDefaultBigInt(w.conf.genesis.Config.EIP155Block)
164+
165+ fmt.Println()
166+ fmt.Printf("Which block should EIP158 come into effect? (default = %v)\n", w.conf.genesis.Config.EIP158Block)
167+ w.conf.genesis.Config.EIP158Block = w.readDefaultBigInt(w.conf.genesis.Config.EIP158Block)
168+
169+ fmt.Println()
170+ fmt.Printf("Which block should Byzantium come into effect? (default = %v)\n", w.conf.genesis.Config.ByzantiumBlock)
171+ w.conf.genesis.Config.ByzantiumBlock = w.readDefaultBigInt(w.conf.genesis.Config.ByzantiumBlock)
172+
173+ out, _ := json.MarshalIndent(w.conf.genesis.Config, "", " ")
174+ fmt.Printf("Chain configuration updated:\n\n%s\n", out)
175+
176+ case choice == "2":
177+ // Save whatever genesis configuration we currently have
178+ fmt.Println()
179+ fmt.Printf("Which file to save the genesis into? (default = %s.json)\n", w.network)
180+ out, _ := json.MarshalIndent(w.conf.genesis, "", " ")
181+ if err := ioutil.WriteFile(w.readDefaultString(fmt.Sprintf("%s.json", w.network)), out, 0644); err != nil {
182+ log.Error("Failed to save genesis file", "err", err)
183+ }
184+ log.Info("Exported existing genesis block")
185+
186+ default:
187+ log.Error("That's not something I can do")
188+ }
189+ }
0 commit comments